我想从我的表中获取今天的记录。我写了以下查询 -
public ICollection<DashboardNotification> GetNotificationOfToday()
{
DateTime todaysDate = DateTime.Now;
DateTime yesterdaysDate = DateTime.Now.AddDays(-1);
db = new BobTheBuilderEntities();
var notificationList = (from n in db.DashboardNotifications.OrderByDescending(n => n.NotificationDateTime)
where (n.NotificationDateTime > yesterdaysDate && n.NotificationDateTime <= todaysDate)
select n).ToList();
return notificationList;
}
但是上面的查询不起作用,因为它也从昨天获取记录。
如何解决这个问题?