有沒有什麼辦法讓僅從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