Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Single WebAPi route, but return multiple entity objects

$
0
0

I have situation where I have to make a call to "api/Department/departmentId" from the Client(asp.net webforms) . I have 1->many relationship between Department and Emplyoee Table.In webApi , I have to make call to both the below methods with the same departmentId as input. I know this is not possible with single route. So , I request sometime to give me an idea , how to achieve this. My dbContext contains both the entites.

public List<Employee> GetEmployeesByDepartmentId(string departmentId)
{
 return dbSet.Where(p => p.DepartmentDepartmentId == departmentId).Select(p => p).ToList();
}

public string GetDepartmentNameByDepartmentId(string departmentId)
{
  return dbSet.Select(p => p.Department.DepartmentName).ToString(); ;
}


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>