[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

【Day04】實戰開始 - 設計版型以及透過Vue框架建立專案

【Day04】實戰開始 - 設計版型以及透過Vue框架建立專案

把問題條列化 - 自主練習

把問題條列化 - 自主練習

SQL For Loop, Using Cursor

SQL For Loop, Using Cursor






留言討論