将实体框架中的DateTime与Sql Server Compact数据库进行比较 [英] Comparing DateTime in Entity Framework with an Sql Server Compact database
本文介绍了将实体框架中的DateTime与Sql Server Compact数据库进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这段代码抛出 System.NotSupportedException
告诉指定的方法'int?尽管DateDiff具有EdmFunction属性,但类型'System.Data.Objects.SqlClient.SqlFunctions'上的DateDiff(string,DateTime ?, DateTime?)'无法转换为LINQ to Entities存储表达式
。 / p>
Why this code throws a System.NotSupportedException
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)
推荐答案
实体SQL查询提供程序链接所支持的规范日期和时间函数的完整枚举。
Here is a complete enumeration of canonical Date and Time functions supported by Entity SQL query provider link.
尝试类似的操作
context.Users.Where(f=>EntityFunctions.DiffSeconds(f.LastLogOn, somedatetime)<0);
这篇关于将实体框架中的DateTime与Sql Server Compact数据库进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文