LINQ to Entity里面不能使用DateTime

LINQ中不能直接使用DateTime,否则会报错:‘The specified type member 'Date' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are support’

需要把DateTime定义在LINQ之外,例如:

            var now = DateTime.Now.Date;
var query = from a in _workPeriodRepository.Table
where a.StartDate <= now && a.EndDate >= now
select a;
return query.ToList();
上一篇:重置mysql管理员密码


下一篇:ASP.NET MVC Json()处理大数据异常解决方法,字符串的长度超过了为 maxJsonLength