I have the following simple table with ID, ContactId and Comment.
I want to select records and GroupBy contactId. I
GroupBy contactId
OrderByDescending
Mains.GroupBy(l => l.ContactID) .Select(g=>g.OrderByDescending(c=>c.ID).FirstOrDefault()) .ToList()
is your best solution
It orders by the highest ID descending, which is pretty obvious from the name.