LINQ in Action roller

Anonymous Type field - why is this not legal?

I've had a few occaisions where I would like to use an already defined anonymous type field and haven't been able to figure this out. Here is what I want to do: List Product > products = new List Product >(); var categories = from p in products group p by p.Category into g select new { Category = g.Key, TotalApples = g.Sum(p => p.ApplesInStock), TotalOranges = g.Sum(p => p.OrangesInStock), TotalFruit = TotalApples + TotalOranges, }; I have to call the sum of Apples & Oranges again on TotalFruit if Read More...
Published Thursday, August 28, 2008 6:09 PM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication