I’m puzzled. I copied this code from the Microsoft LINQ examples site, but can’t get it to compile.
I want to do something similar, but it says it cannot resolve symbol minPrice, and a bunch of other errors. What gives?
public void Linq84() { List products = GetProductList(); var categories = from p in products group p by p.Category into g from minPrice = g.Group.Min(p => p.UnitPrice) select new {Category = g.Key, CheapestProducts = g.Group.Where(p => p.UnitPrice == minPrice)}; ObjectDumper.Write(categories, 1); }
I think that the query has some typos, or was made in the early stages of Linq.
I’ll rewrite it as this:
BTW, as good learning resources I highly recommend you LinqPad which is a great tool and HookedToLinq.