I am trying to join two tables employee and department using LINQ and trying to get results in given below image format. Can some one help how to achieve this.
how to achieve employees present in each department.
Here is my code
var EmpList = (from d in Department
join e in Employee on d.ID equals e.ID
select new
{
ID = d.ID, Name = d.Name, Location = d.location, Employess =
e.FirstName, e.LastName, e.Gender
});
The above code not fully written. I am not getting any ideas how to achieve this.
var elist = from d in db.Departments
join e in db.Employees on d.ID equals e.ID
group d by e.DepartmentId into g
select new { Details = g };