views:

73

answers:

0

I'm having a bit of trouble doing an inline .GroupBy() and .Sum() action.

I have a subset of data obtained via a let so it's return type is already anonymous. Hopefully there's enough code in this sample to show what I'm trying to achieve...

from r in Repo.R
  join f in Repo.F
    on f.ID equals r.FFK

let totalB = Repo.B
    .Join(
        b => b.FKID,
        f => f.ID
        (b, f) => new { b.ID, b.Qty, b.Fee })
    .Where(
        b => b.someCriteria == someInput)

group r by new 
   { 
      r.Name,
      TotalFee = totalB
                 .GroupBy(tb => tb.TypeId)
                 .Sum(  /*having trouble here*/ )
   }
into rgroup
select new FinalOutput
   {
        rgroup.Key.Name,
        rgroup.Key.TotalFee
   }

I need a valid:

Func<IGrouping<int, anonymous type>, int> selector

or

Expression<Func<IGrouping<int, anonymous type>, decimal>> selector