My Model is given as:
public class Department
{
// just keeping it relevant
public List<Job> Jobs { get; set; }
}
public class Job
{
public int ID { get; set; }
public string Name { get; set; }
}
And I want to select the Jobs that belong to the specific department and convert them into Selectlist so that i can pass them to View.
What I have done in the controller is( yes i am hardcoding the id with value 1):
ViewBag.JobID = new SelectList( db.Departments.Where(x => x.ID == 1).Select(m => m.Jobs, "ID","Name");
But I am getting the following error,
List does not contain a property with the name 'ID'