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






你可能感興趣的文章

[FE302] React 基礎 ( hooks 版 ):React 基礎

[FE302] React 基礎 ( hooks 版 ):React 基礎

Day04 - CSS內距、邊框、輪廓與邊界範圍

Day04 - CSS內距、邊框、輪廓與邊界範圍

台灣如何買虛擬貨幣

台灣如何買虛擬貨幣






留言討論