Using mvc3 and entity framework 4.
In sql server, the “Steps” table has foreign key constraint to “Question” via stepID.
The query (below) steps includes any associated questions.
var steps = from b in db.Steps.Include(s => s.Questions)
orderby b.StepOrder
select b;
return View(steps.ToList());
I want to also pull “answers” associated to questions.
In sql server, the “Questions” table has foreign key contraint to “Answers” via questionID.
How do I change the query to include answers associate to questions which are associated to steps?
You need to
Selectthe grandchildren inside theIncludeSee Eagerly loading multiple levels section in the Loading Related Entities EF tutorial.