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






你可能感興趣的文章

[PySide6]QMainWindow - 功能表

[PySide6]QMainWindow - 功能表

瞭解function-注意物件

瞭解function-注意物件

[VSCode] 在 Remote-SSH 時使用 power mode 效果

[VSCode] 在 Remote-SSH 時使用 power mode 效果






留言討論