system.DateTime ToDateTime(System.String)”,因此该方法无法转换为存储表达式-解决方法

LINQ to Entities的lambda表达式中如果需要转换时间及各种时间格式请使用System.Data.Entity的类DbFunctions的各种方法

例如:

IsOverdue = db.Order.Where(p => p.RealRepaymentDate > DbFunctions.AddMinutes(DbFunctions.AddHours(DbFunctions.TruncateTime(p.RepaymentDate), 23),59)).Count() >0,

 这里是构造一个无限接近24点的日期时间来进行对比(2018-11-08 23:59:00) 

原文地址:https://www.cnblogs.com/firstcsharp/p/9932560.html