开发者

Comparing DateTime in Entity Framework with an Sql Server Compact database

Why this code throws a System.NotSupportedExceptio开发者_如何学编程n telling that The specified method 'int? DateDiff(string, DateTime?, DateTime?)' on the type 'System.Data.Objects.SqlClient.SqlFunctions' cannot be translated into a LINQ to Entities store expression, though DateDiff has EdmFunction attribute?

context.Users.Where(f => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("second", f.LastLogOn, somedatetime) < 0)


Here is a complete enumeration of canonical Date and Time functions supported by Entity SQL query provider link.

Try something like this

context.Users.Where(f=>EntityFunctions.DiffSeconds(f.LastLogOn, somedatetime)<0);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜