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






你可能感興趣的文章

MSSQL 的觸發程序 TRIGGER

MSSQL 的觸發程序 TRIGGER

w17 hw2 餐廳網頁改寫

w17 hw2 餐廳網頁改寫

謂詞邏輯(Predicate Logic)

謂詞邏輯(Predicate Logic)






留言討論