A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
I'm still not sure what the error is and I'm not a fan of returning anonymous types but the following is a typical Web API pattern.
[HttpGet("/api/Employee/GetEmployeeByName/{name}/{surname}")]
public async Task<ActionResult> GetEmployeeByName(string name, string surname)
{
var result = await _context.Employees
.Where(e => e.Name == name & e.Surname == surname)
.Select(e => new { id = e.EmployeeId, deptId = e.DepartmentId }).ToListAsync();
if (result == null | result?.Count() == 0)
{
return NotFound();
}
return Ok(result);
}
The results
[
{
"id": 1,
"deptId": 1
}
]
If the response is empty perhaps it is a case issue?
.Where(e => e.Name.ToLower() == name.ToLower() & e.Surname.ToLower() == surname.ToLower())