Lui*_*uis 2 linq datetime linq-to-entities date
我需要得到当天的查询,问题是当我尝试将来自DB(即a DateTime)的DateTime.Today.Date值与值进行比较时,我收到错误.
我想要实现的是获得当天的寄存器.
List<Client> _cliente = from c in db.Cliente
join v in db.Vendedor
on c.IDVendedor equals v.IDVendedor
where v.Fecha.Date.Equals(DateTime.Today.Date)
Run Code Online (Sandbox Code Playgroud)
这就是我得到的:'LINQ to Entities中不支持指定的类型成员'Date'.仅支持初始化程序,实体成员和实体导航属性.
也许你可以这样做:
var today = DateTime.Today;
var tomorrow = today.AddDays(1);
List<Client> _cliente = from c in db.Cliente
join v in db.Vendedor
on c.IDVendedor equals v.IDVendedor
where v.Fecha >= today && v.Fecha < tomorrow
Run Code Online (Sandbox Code Playgroud)