📜  c# linq distinct group by 嵌套列表 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:07.189000             🧑  作者: Mango

代码示例1
var result = hotels.SelectMany(hotel => hotel.RoomType.Select(room => new { Id = room.RoomId, Hotel = hotel }))
                   .GroupBy(item => item.Id)
                   .Select(group => group.FirstOrDefault());