帮助实体框架对象的C#linq查询

时间:2011-09-01 13:50:43

标签: c# linq entity-framework

我在Entity Framework中有一个表示电话呼叫的Call对象。

有人可以通过linq查询帮助我吗?

我需要返回日期范围之间拨打的前40个号码,包括拨打号码的次数

由于

1 个答案:

答案 0 :(得分:3)

听起来像你想要的东西:

var query = (from call in db.PhoneCalls
             where call.Date >= minDate && call.Date <= maxDate
             group call by call.Number into g
             orderby g.Count() descending
             select new { Number = g.Key, Count = g.Count() })
            .Take(40);

根据您告诉我们的内容,这只是猜测......