C#实现DataTable按天分组并计数
使用LINQ语句进行查询
var value = from data in dataSet.Tables[0].AsEnumerable()
//where before <= data.Field<DateTime>("alarmTime") &&
// data.Field<DateTime>("alarmTime") <= now
group data by data.Field<DateTime>("alarmTime").ToString("yyyy-MM-dd")
into r
select new
{
count = r.Count()
};
访问数据
foreach (var v in value)
{
Console.WriteLine(v.vount);
}