【发布时间】:2014-02-12 19:03:51
【问题描述】:
如何只比较 DateTime 对象的时间而不得到以下结果
错误:
An exception of type 'System.NotSupportedException' occurred in mscorlib.dll but was not handled in user code Additional information: The specified type member 'TimeOfDay' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
我的代码:
var date = DateTime.Parse(query.DueTime);
entities = entities.Where(r => r.DueTime.TimeOfDay.Equals(date.TimeOfDay));
【问题讨论】: