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






你可能感興趣的文章

C 語言練習程式(6) -- 指標相關程式集錦(5)

C 語言練習程式(6) -- 指標相關程式集錦(5)

6. 排序 (上篇)

6. 排序 (上篇)

Explore-Array and String

Explore-Array and String






留言討論






2
2
2