Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# linq distinct group by nested list

var result = hotels.SelectMany(hotel => hotel.RoomType.Select(room => new { Id = room.RoomId, Hotel = hotel }))
                   .GroupBy(item => item.Id)
                   .Select(group => group.FirstOrDefault());
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #linq #distinct #group #nested #list
ADD COMMENT
Topic
Name
9+1 =