[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人工智能] python 錯誤訊息及解決方式

[AI人工智能] python 錯誤訊息及解決方式

BTC original source code(C++) initial 架構分析  (1)

BTC original source code(C++) initial 架構分析 (1)

React-[基礎篇]- 基礎篇與state篇的大綱

React-[基礎篇]- 基礎篇與state篇的大綱






留言討論