Given two classes named as Employee and Department, now we join Employee and Department class with the help of LINQ join Query. So to this task, we use the Join clause. This clause is used to join two data sources into one source which has some common attributes. It always takes two data sources and the result of the join depends upon which type o join is used like inner join, cross join, left outer join, and group join.
Input:
Student
new Employee{id = 7058, name = "sravan kumar", dept_id = 1, add_id = 21},
new Employee{id = 7059, name = "jyothika", dept_id = 2, add_id = 22},
new Employee{id = 7072, name = "harsha", dept_id = 1, add_id = 22},
new Employee{id = 7076, name = "khyathi", dept_id = 4, add_id = 27},
Department
new Department{dept_id = 1, dept_name = "CSE"},
new Department{dept_id = 2, dept_name = "CSE"},
new Department{dept_id = 3, dept_name = "IT"},
Address
new Address{add_id = 21, address_name = "hyd"},
new Address{add_id = 22, address_name = "railu-peta"},
new Address{add_id = 24, address_name = "chenchu-peta"},
Output:
ID: 7058--> Name: sravan kumar--> Department: CSE--> Address: hyd
ID: 7059--> Name: jyothika--> Department: CSE--> Address: railu-peta
ID: 7072--> Name: harsha--> Department: CSE--> Address: railu-peta