Subsonic 3.0 ActiveRecord 带日期
我在查询时遇到了一些麻烦。
在我的数据库中,日期时间存储为 YYYY-MM-dd HH:mm:ss
我有以下 LINQ 查询:
var visitors = Visitor.All().Where(x=>x.Date_Moderated < dateTime).OrderByDescending(x => x.Date_Moderated).Take(limit);
问题是这被转换为:
SELECT TOP (100) [t0].VisitorId, <COLUMNS TRUNCATED FOR BREVITY AND PRIVACY>
FROM [dbo].[Visitor] AS t0
WHERE ([t0].[Date_Moderated] < '07/12/2010 18:53:58')
ORDER BY [t0].[Date_Moderated] DESC
如您所见,日期参数的格式不正确,SQL Server 将此转换为到美国日期时间,所以当我实际上应该得到 100 时我没有得到任何结果。
有谁知道如何使 Subsonic 正确格式化日期?或者是构建查询的更好方法。
问候, 抢
I'm having a little trouble with a query.
In my database datetimes are stored as YYYY-MM-dd HH:mm:ss
I have the following LINQ query:
var visitors = Visitor.All().Where(x=>x.Date_Moderated < dateTime).OrderByDescending(x => x.Date_Moderated).Take(limit);
The problem is this is translated to:
SELECT TOP (100) [t0].VisitorId, <COLUMNS TRUNCATED FOR BREVITY AND PRIVACY>
FROM [dbo].[Visitor] AS t0
WHERE ([t0].[Date_Moderated] < '07/12/2010 18:53:58')
ORDER BY [t0].[Date_Moderated] DESC
As you can see the date parameter is not in the correct format and SQL Server converts this to US datetime and so I am getting no results when I should in fact get 100.
Does anyone know how to make Subsonic format the date correctly? Or alternatively a better way to structure my query.
Regards,
Rob
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将查询更改为以下内容解决了这个问题:
I have solved this by changing my query to the following: