I have the following linq query, which works fine. I\'m not sure how i order the group\'d result.
from a in Audits
join u in Users on a.UserId equals u.UserI
var results =
(from a in Audits
join u in Users on a.UserId equals u.UserId
group a by a.UserId into g
select new { UserId = g.Key, Score = g.Sum(x => x.Score) })
.OrderByDescending(p=>p.Score);
Hope this will fix your problem, easier than the top one ;)
Cheers
Just add the orderby clause ;-)
from a in Audits
join u in Users on a.UserId equals u.UserId
group a by a.UserId into g
let score = g.Sum(x => x.Score)
orderby score descending
select new { UserId = g.Key, Score = score };