I have the following code to join two tables in an ASP.NET MVC controller but I also want to display employee's supervisor name from the same table and same filed.
But I get an error:
An anonymous type cannot have multiple properties with the same name
Here is my code
public IHttpActionResult GetEmployees()
{
var query = (from n in db.Employees
join c in db.tblCities on n.ProjectID equals c.CityID
into nc
from c in nc.DefaultIfEmpty()
join manager in db.Employees on n.ManagerName equals manager.Name
into pc
from managerin pc.DefaultIfEmpty()
select new
{
n.Name,
manager.Name,
n.Email,
c.CityName
});
var employees = query.ToList();
return Ok(employees);
}
What is the workaround to accomplish my goal?