I have the following simple table with ID, ContactId and Comment.
I want to select records and GroupBy contactId. I
GroupBy contactId
You could use MoreLinq like this for a shorter solution:
Main.OrderByDescending(i => i.Id).DistinctBy(l => l.ContactID).ToList();