首页 > 代码库 > linq日期查询

linq日期查询

            //获取当天的数据
            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());

 

linq日期查询