I have this expression:
group i by i.ItemId into g
select new
{
Id = g.Key,
Score = g.Sum(i => i.Score)
}).ToDictionary(o => o.Id, o => o.Score);
and instead g.SumI would like to get a math product using Aggregate.
To make sure that it works the same way .Sum(but as a product), I tried to make an Aggregate function that just returns the amount ...
Score = g.Aggregate(0.0, (sum, nextItem) => sum + nextItem.Score.Value)
However, this does not give the same result as when used .Sum. Any ideas why?
nextItem.Scorehas type double?.
source
share