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






你可能感興趣的文章

雜湊表(Hash Table)

雜湊表(Hash Table)

SQL-injection專論 (2) -- UNION攻擊(2)

SQL-injection專論 (2) -- UNION攻擊(2)

更新 Node 的版本

更新 Node 的版本






留言討論