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






你可能感興趣的文章

工程師有兩種:做完跟做好的分別

工程師有兩種:做完跟做好的分別

4.  在 JSX 中使用 JavaScript

4. 在 JSX 中使用 JavaScript

Vue3 Teleport 將元件指定位置

Vue3 Teleport 將元件指定位置






留言討論






2
2
2