[C#] LINQ Group By


Feb 10, 2023

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#






你可能感興趣的文章

[FE201]  gulp 幫你管理任務的 library

[FE201] gulp 幫你管理任務的 library

Angular17 部屬完成,在瀏覽器中使用 F5 重新整理跳轉 404 異常解決

Angular17 部屬完成,在瀏覽器中使用 F5 重新整理跳轉 404 異常解決

團隊的推進器 — 開放與學習

團隊的推進器 — 開放與學習






留言討論