[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#






你可能感興趣的文章

AI輔導室|立體環形文字

AI輔導室|立體環形文字

信用卡資訊分享 || 2020 下半年

信用卡資訊分享 || 2020 下半年

程式設計學習筆記01

程式設計學習筆記01






留言討論