public void Linq87()
{
List products = GetProductList();
var categories =
from p in products
group p by p.Category into g
select new { Category = g.Key, MostExpensivePrice = g.Max(p => p.UnitPrice) };
ObjectDumper.Write(categories);
}
Result
Category=Beverages
Category=Condiments
Category=Produce
Category=Meat/Poultry
Category=Seafood
Category=Dairy Products
Category=Confections
Category=Grains/Cereals
MostExpensivePrice=263.5000
MostExpensivePrice=43.9000
MostExpensivePrice=53.0000
MostExpensivePrice=123.7900
MostExpensivePrice=62.5000
MostExpensivePrice=55.0000
MostExpensivePrice=81.0000
MostExpensivePrice=38.0000