0

尽管 DateDiff 具有 EdmFunction 属性,为什么这段代码会抛出一个System.NotSupportedException提示?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

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

1 回答 1

2

这是 Entity SQL 查询提供程序链接支持的规范日期和时间函数的完整枚举。

尝试这样的事情

context.Users.Where(f=>EntityFunctions.DiffSeconds(f.LastLogOn, somedatetime)<0);
于 2010-07-05T21:27:08.607 回答