I have two LINQ statements that I would like to do in one, but for life I can't get it to work.
I can not get the group to work in the first expression. He complains that there are no TotalBuy and TotalSell properties, although he does not complain about AmountTC and AmountAUD .
It should be easy. Any thoughts?
var itineraryItems = from ii in this.ItineraryItemRecords join t in this.TransactionRecords on ii.OperatorID equals t. TransactionActor.OperatorID into g select new { OperatorID = ii.OperatorID, TotalBuy = g.Sum(i = >ii.TotalBuy) , TotalSell = g.Sum(i = >ii.TotalSell) , PaidTC = (0 - (g.Sum(t = >t.AmountTC))) , PaidAUD = (0 - (g.Sum(t = >t.AmountAUD))) }; var itineraryItemz = from i in itineraryItems group i by i.OperatorID into g select new { OperatorID = g.Key, TotalBuy = g.Sum(i = >i.TotalBuy) , TotalSell = g.Sum(i = >i.TotalSell) , PaidTC = (0 - (g.Sum(i = >i.PaidTC))) , PaidAUD = (0 - (g.Sum(i = >i.PaidAUD))) };
As a side note, ItineraryItemRecords and TransactionRecords are collections of classes handled by SubSonic .
It really should be easy, so any help would be appreciated.
Regards, John
source share