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






你可能感興趣的文章

我的gulpfile.js要怎麼撰寫

我的gulpfile.js要怎麼撰寫

[css] 網頁字型渲染的優化

[css] 網頁字型渲染的優化

筆記、[ALG101] 看懂題目+寫程式

筆記、[ALG101] 看懂題目+寫程式






留言討論