I have a query that sums and aggregates alot of data something like this:
var anonType = from x in collection
let value = collection.Where(c=>c.Code == "A")
select new { sum = value.Sum(v=>v.Amount) };
I find it really weird that I have to declare the range variable x, especially if I'm not using it. So, am I doing something wrong or is there a different format I should be following? Also, keep in mind that anonType has about 15 different properties that are all types of aggregates (sums,counts, etc). So I couldn't do something like:
int x = collection.Where(c=>c.Code == "A").Sum(v=>v.Amount);