Search
 
SCRIPT & CODE EXAMPLE
 

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());
Comment

PREVIOUS NEXT
Code Example
Csharp :: gcd of list of number 
Csharp :: timespan to integer c# 
Csharp :: qtablewidget add image 
Csharp :: ffmpeg add audio to video at specific time 
Csharp :: google script get time 
Csharp :: difference between boxing and unboxing in c# 
Csharp :: wpf resource dictionary 
Csharp :: How to catch Entity Framework Errors C# 
Csharp :: linq query to check if record exists 
Csharp :: c# distinct array of objects by values 
Csharp :: copy class c# 
Csharp :: c# use api rest 
Csharp :: c# windows forms open directory in explorer 
Csharp :: IHttpContextAccessor 
Csharp :: get file path in .net core from wwwroot folder 
Csharp :: how to change dictionary value in c# 
Csharp :: C# setting property values through reflection with attributes 
Csharp :: c# Predicate delegate 
Csharp :: linq when name then orderby 
Csharp :: msbuild publish to folder command line .net 
Csharp :: how to add a force to an object unity 
Csharp :: c# get classes which inherits 
Csharp :: get last index C# 
Csharp :: how to store some variables on the device in unity 
Csharp :: c# yield keyword 
Csharp :: c# split string by index 
Csharp :: on trigger unity 
Csharp :: tostring format 2 decimals 
Csharp :: c# remove time in datetime 
Csharp :: mysqldump - date 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =