c# linq distinct list of objects code example
Example 1: how to use distinct in linq query in c#
var distValues = objList.Select(o=>o.typeId).Distinct().ToList();
Example 2: 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());