The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties

出现这个错误提示可以用 DbFunctions.TruncateTime 将Linq中entity的DateTime转化一下再使用,如下所示:

var anyCalls = _db.CallLogs.Where(x => DbFunctions.TruncateTime(x.DateTime) == callDateTime.Date).ToList();

更多详细解答请看如下链接:

http://stackoverflow.com/questions/14601676/the-specified-type-member-date-is-not-supported-in-linq-to-entities-only-init 

 

Date vs DateTime

http://stackoverflow.com/questions/798121/date-vs-datetime 

 

posted @ 2015-11-14 21:39  Eric Sun  阅读(876)  评论(0编辑  收藏  举报