I have a EF “Call” class which has a date, telephone number, caller name, and call cost.
My aim is to group the calls by the telephone number, and sum the total cost, and take the results of the 40 most expensive calls. I have all of this working, but I am having trouble with the projection, how do I get access to caller name?
var query =
(
from call in model.Calls
group call by call.TelephoneNumber into g
orderby g.Sum(gr => gr.ActualCost) descending
select new
{
TelephoneNumber = g.Key,
CallerName = ???
Cost = (g.Sum(gr => gr.ActualCost)),
TotalNumbers = g.Count(),
}
).Take(40);
You need group on the CallerName also: