Bind the Data like Parent Child relationship using entities (LINQ)

Entities
  1. public class Department   
  2. {  
  3.     public int DeptID {getset;}  
  4.     public string DeptName {get;set;}  
  5. }  
  6.   
  7. public class EmpDept   
  8. {  
  9.     public int DeptID { get;set;}  
  10.     public string DeptName {get;set;}  
  11.     public List < Employee > employee {get;set;}  
  12. }  
  13.   
  14. public class Employee   
  15. {  
  16.     public int EmpID {get;set;}  
  17.     public int DeptID {get;set;}  
  18.     public string Name {get;set;}  
  19. }  
Sample Data for Employee and Department entities object
  1. List < Department > objDeptCollection = new List < Department > () {  
  2.     new Department() {  
  3.         DeptID = 1, DeptName = "Finance"  
  4.     }, new Department() {  
  5.         DeptID = 2, DeptName = "L&D"  
  6.     }, new Department() {  
  7.         DeptID = 3, DeptName = "HR"  
  8.     }, new Department() {  
  9.         DeptID = 4, DeptName = "DEV"  
  10.     }  
  11. };  
  12.   
  13. List < Employee > objEmpCollection = new List < Employee > () {  
  14.     new Employee() {  
  15.         DeptID = 1, EmpID = 11, Name = "Sudheer"  
  16.     }, new Employee() {  
  17.         DeptID = 1, EmpID = 12, Name = "Suneel"  
  18.     }, new Employee() {  
  19.         DeptID = 2, EmpID = 13, Name = "Ramu"  
  20.     }, new Employee() {  
  21.         DeptID = 2, EmpID = 14, Name = "Pavani"  
  22.     }, new Employee() {  
  23.         DeptID = 3, EmpID = 15, Name = "Ishita"  
  24.     }, new Employee() {  
  25.         DeptID = 4, EmpID = 16, Name = "Yagna"  
  26.     }, new Employee() {  
  27.         DeptID = 1, EmpID = 17, Name = "Sravanthi"  
  28.     }, new Employee() {  
  29.         DeptID = 3, EmpID = 18, Name = "Kyathi"  
  30.     }  
  31. };  
LINQ Query to map the objects into single Parent and child object
  1. List < EmpDept > objBoth = new List < EmpDept > ();  
  2. objBoth = (from emp in objEmpCollection  
  3. join dept in objDeptCollection on emp.DeptID equals dept.DeptID  
  4. select(new EmpDept {  
  5.     DeptID = dept.DeptID, employee = new List < Employee > {  
  6.         new Employee {  
  7.             DeptID = emp.DeptID, Name = emp.Name, EmpID = emp.EmpID  
  8.         }  
  9.     }  
  10. })).ToList();