Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have Some customers Are shown in Table
Those who had the most number of shopping With this way I Found Them
SQL
return View(order.OrderByDescending(top=> top.UserID.Count()).Take(10));



Now I Wanna Found Anyone who has purchased With the maximum amount Like
SQL
order.Sum(top=> top.Amount).Take(10)


If U have Idea Help Me Thank Guys
Posted
Comments
bbirajdar 18-May-13 15:53pm    
order.OrderByDescending(top=> top.Amount).Take(10)
Ali Javani 30-May-13 1:30am    
Thanx So Much This Use Full
Ali Javani 19-May-13 1:13am    
Hi Thanks For Comment But it Dosen't Work For this job.. Think Sum OF All Payment in the Table From one Customer ;) i can do that with ForEach() But i know it should be work with Lambda..
anyway thanks .

1 solution

You need two steps. You need to select Max to get the maximum amount. Then you can select based on that value. You might be able to do order.Where(top => top.Amount == top.Amount.Max()) but I doubt it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900