How to select last record in a LINQ GroupBy clause

后端 未结 5 906
长发绾君心
长发绾君心 2020-12-11 03:06

I have the following simple table with ID, ContactId and Comment.

I want to select records and GroupBy contactId. I

5条回答
  •  死守一世寂寞
    2020-12-11 04:06

    You could use MoreLinq like this for a shorter solution:

    Main.OrderByDescending(i => i.Id).DistinctBy(l => l.ContactID).ToList();
    

提交回复
热议问题