网站链接: 我爱捣鼓
当前位置: 首页 > 数据库  > Linq

The specified type member 'Date' is not supported in LINQ to Entities.

2021/2/21 19:37:57

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 = D…

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();


相关资讯

    暂无相关的数据...