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






你可能感興趣的文章

react-redux 錯誤訊息:...is missing in props validation

react-redux 錯誤訊息:...is missing in props validation

Virtual DOM 實作與原理解析

Virtual DOM 實作與原理解析

Git change specific commit message

Git change specific commit message






留言討論