Return max and min in the same query?
LINQ
2
Posts
2
Posters
2
Views
1
Watching
-
Hi, If I have a table in my db, lets say it has the columns "name", "price", "quantity". How can i write a LINQ query that returns max/min price and min/max quantity in the same query? Anybody having an idea how to do this?
Off the top of my head:
from p in Purchases
group p by p.Price into q
select new { MaxPrice = q.Max(r=>r.Price), MinPrice = q.Min(p=>p.Price) }Deja View - the feeling that you've seen this post before.