有没有什么办法让仅从DateTime.Now
Date
那也将是类型的DateTime
。因为在我的数据库有CreatedDate
属性,它是DateTime
类型。我如何在LINQ比较日期(同样像SQL查询)
var cmd = _ut.GetRepoInstance<Feedback>().GetAllRecords().Where(x => x.IsStatus == true & x.CreatedDate== DateTime.Now).Count();
有人建议可以Linq查询将在DateTime.Now
从C#和DateTime
类型之间的比较仅日期部分从SQL
'DateTime.Now.Date'给出了'Date'部分权? – Chaitanya
我假设你通过linqtosql查询数据库,并且我已经使用了DbFunctions。 var cmd = _ut.GetRepoInstance().GetAllRecords()。其中(x => x.IsStatus == true&DbFunctions.TruncateTime(x.CreatedDate)== DbFunctions.TruncateTime(DateTime.Now))。Count(); –
Rangesh