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






你可能感興趣的文章

在臺灣與世界做朋友-我在 TourMeAway 的英語導覽經驗回顧

在臺灣與世界做朋友-我在 TourMeAway 的英語導覽經驗回顧

CSS保健室|background

CSS保健室|background

使用 Sass 管理 CSS

使用 Sass 管理 CSS






留言討論