为什么这段代码抛出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
,虽然DateDiff有EdmFunction属性?
context.Users.Where(f => System.Data.Objects.SqlClient.SqlFunctions.DateDiff("second", f.LastLogOn, somedatetime) < 0)
答案 0 :(得分:2)
以下是Entity SQL查询提供程序link支持的规范日期和时间函数的完整枚举。
尝试这样的事情
context.Users.Where(f=>EntityFunctions.DiffSeconds(f.LastLogOn, somedatetime)<0);