My Code is :
public class EmployeeController : ApiController
{
ASITDbEntities db = new ASITDbEntities ( );
// GET api/employee
public IEnumerable<Employee> Get ( )
{
db.Configuration.ProxyCreationEnabled = false;
var result=db.Employees.ToList ()
return result.ToList ( );
}
}
I want to return employee district name from District table. It returns only district Id.
I tried db.Employee.Include(e=>e.district).Tolist();
But that did not work. Please help me.
db.Employees.Include(e=>e.district).Tolist();shouuld do the trick unless there isn't actually a value set in the database for thedistrictId.Employeehas something likeDistrictIdit's almost certain that you can add a navigation propertyDistrictto it.