[C#] LINQ Group By


Feb 10, 2023

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#






你可能感興趣的文章

Spring boot系列(五)Controller-Parameter

Spring boot系列(五)Controller-Parameter

MVC ,utility模組(工具), 常數(不會變動的資料)

MVC ,utility模組(工具), 常數(不會變動的資料)

JavaScript  與瀏覽器的溝通 : DOM

JavaScript 與瀏覽器的溝通 : DOM






留言討論






2
2
2