Santosh Kumar

Santosh Kumar

  • NA
  • 126
  • 59.8k

How combine two or more lists into one list

Apr 13 2018 11:39 AM
Hi Friends, 
 I am having a requirement like below. 
 class Final
 {
 public string EmployeName{get;set;} 
public string Gender{get;set;}
 public string DepartId{get;set;} 
public string DepartName{get;set;} 
public string SalaryId{get;set;}
 public string Salary{get;set;}
 } 
 class Emp {
 public string EmployeName{get;set;} 
public string Gender{get;set;}
  }  
class Department {
 public string DepartId{get;set;
} public string DepartName{get;set;} 
} class Salary 
{ public string SalaryId{get;set;} public string Salary{get;set;}
 }
 Having the list of Final, Emp, Department and Salary like below 
 lstFinal, lstEmp,lstDepartment,lstSalary  
 Want a linq query with  final list to be a combination of lstEmp, lstDepartment,lstSalary  

Please kindly help me out. 
What I have tried:  
var result= from e Emp   join d in dept on e.EmployeName equals e.EmployeName  
join g in gend on g.Gender equals g.Gender
 select new Final(){EmployeName=e.EmployeName, Gender=e.Gender, DepartId=d.DepartId, DepartName=d.DepartName,SalaryId=s.SalaryId,Salary=s.Salary}

Answers (2)