I have the query:
var q =
(
from c in db.tblArcadeGamePlays
join a in db.tblProfiles on c.UserID equals a.UserID
where c.UserID != 0
orderby c.Date descending
select new { c.UserID, c.tblForumAuthor.Username, a.EmailAddress }
)
.Distinct()
.Take(12);
This takes the correct records, but isn’t ordering them. If I switch the orderby to asc/desc it has no affect! Can anyone point out what I can do to return the records newest first?
Edit
It’s returning the correct ordering of results if the Distinct() is removed, but it’s now returning the same user record over and over again (I only want each user to appear once)
It sounds like you want the
distinctlist to be ordered by the newest item in each set, right?To do this, you should use a
group by. You’ll have toordertwice, once within each set, and once again for the entire list:The
orderbypart might look confusing, but it’s simply: order the groups by the first date within each group