Reputation: 898
I have a simple data structure
My question is, how can I eagerly load specific Employee's education list and each education's university and department information in Entity Framework.
In ASP.NET MVC tutorials there is a query like:
var viewModel = new InstructorIndexData();
viewModel.Instructors = db.Instructors
.Include(i => i.OfficeAssignment)
.Include(i => i.Courses.Select(c => c.Department))
.OrderBy(i => i.LastName);
But my include takes only string parameter (with using System.Linq)
How can I solve this problem?
Thank you...
Upvotes: 2
Views: 2037
Reputation: 60493
Is't not in System.Linq, but in System.Data.Entity (so using System.Data.Entity) and exists in EF 4.1, but I must admit I don't know in which version it appeared.
Upvotes: 4
Reputation: 273229
That snippet is for a new version of EF I thin. What 4.x version are you using?
You should be able to use the name(s) of the Navigation properties:
viewModel.Instructors = db.Instructors
.Include("OfficeAssignment")
.Include("Courses.Department") // not so sure about this one
.OrderBy(i => i.LastName);
Upvotes: 2