LINQ to Entities 比较日期

时间:2022-12-27 13:57:15
//获取当天的数据
DrawRecordDA _recordDA = new DrawRecordDA();
var query = _recordDA.GetQuery();

//筛选 当天
//query = query.Where(q=>SqlFunctions.DateDiff("day",q.AddTime,DateTime.Now)==0);

//筛选 当天
// query = query.Where(q=>q.AddTime.Day==DateTime.Now.Day);
//筛选 本周
query = query.Where(q => SqlFunctions.DateDiff("week", q.AddTime, DateTime.Now) == 0);

Console.WriteLine(query.Count());