Linq group by month

Ver*_*009 -1 linq linq-to-sql c#-4.0

我有一个带有日期字段和时间字段的表.我想检索按月份分组的结果集以及该月份内出现的记录数.如何在LINQ中完成?像这样的东西.

数据.

10/10/2011 00:00:10:000
10/11/2011 00:00:20:000
11/01/2011 00:00:10:000
11/10/2011 00:00:40:000

我想要检索

10/1/2011 00:00:30:000
11/1/2011 00:00:50:000

谢谢你的帮助.

我尝试这样的事情.

var monthely = 
  from u in sqlDataContract.TimeTrickTables 
  group u by u.EntryDate.Value.Month into g 
  select new 
  { 
    EntryDate = g.Key, 
    ETime = g.Aggregate(TimeSpan.Zero, (subtotal, t) => subtotal.Add((TimeSpan)t.ETime)) 
  };
Run Code Online (Sandbox Code Playgroud)

但它抛出此异常 不支持查询运算符'Aggregate'

Mag*_*nus 5

from u in TimeTrickTables
group u by u.EntryDate.Value.Month into g
select new
{
    Month = g.Key,
    Count = g.Count(), //Nr. of records
    Time = new TimeSpan(g.Sum(x => x.ETime.Ticks)) //Total time
}
Run Code Online (Sandbox Code Playgroud)