
code:
- var all = db.Content.Where(c => c.UserId == userId &&
- DbFunctions.DiffDays(c.CreateTime,nowDate)==0).Count();
如果是查询当前的而不是一个时间范围其实查询大于当天的即可
- DateTime nowDate = DateTime.Now.Date;
- return context.Article.Where(a => a.UserId == userId && a.CreateDate > nowDate).Count();
这算是一个比较好的小技巧不需要一个时间范围了
评价