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






你可能感興趣的文章

每日心得筆記 2020-06-12

每日心得筆記 2020-06-12

Node.appendChild() vs. Element.append()

Node.appendChild() vs. Element.append()

29 Incrementer 7 kyu

29 Incrementer 7 kyu






留言討論