我使用 EF 4,我的DateTimeStart
实体中有一个属性,日期格式为这种格式16/08/2012 08:14:40
,我想用 EF 查询并找到所有实体within the date 16/08/2012 only
。使用下面的代码我收到此错误
The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
我的代码
DateTime dateTimeNow = DateTime.UtcNow;
DateTime dateNow = dateTimeNow.Date;
return db.EventCustoms.Where(x => x.DataTimeStart.Date <= dateNow)
.Select(y => new { y.EventId, y.EventTitle, y.DataTimeStart });