I have a .net core(v 3.1) in which i have installed Microsoft SQL Server database provider nuget package for Entity Framework Core.
I want to get only two feilds from the database?
Error : Severity Code Description Project File Line Suppression State Error CS0266 Cannot implicitly convert type 'System.Linq.IQueryable<<anonymous type: string Name, string Number>>' to 'ExampleAuth.Model.Employee'. An explicit conversion exists (are you missing a cast?)
public Employee GetById(int id)
{
var response = db.Employee.Where(x => x.Id == id).Select(x => new{x.Name,x.Number});
return response;
}
API Is...
[HttpGet]
[Route("GetById/{id}")]
public Employee GetById(int id)
{
if (id != 0)
{
return bl.GetById(id);
}
else
{
throw new Exception("! No Data Found");
}
}