[英]How to get the current month date wise records using linq to sql?
我希望得到本月每天的行数,如下所示:
Date count
1/03/2013 18
2/03/2013 41
28/03/2013 12
29/03/2013 14
如何编写查询?
因此,我假设您有一些日期时间字段的表,其中日期为“1/03/2013”18次,这意味着该表中有18行具有该日期。
然后你应该得到一年中每个月的每一天的计数:
var year = 2013;
var month = 3;
var q = from t in DBContext.TableName
where t.DateField.Year == year && t.DateField.Month == month
group t by t.DateField.Date
into g
select new
{
dateField = g.Key,
countField = g.Count()
};
另请参见LINQ to SQL示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.