Include grandchildren - eager loading in EF Entity Framework

C#Entity Framework

Please contribute by voting. Thanks!
2
This is how do you eager load grand children entities:
var customers = db.Customers.Include(p => p.CustomerTags.Select(i => i.Tag));

This also applies to great-grandchildren as well in the following manner:
var customers = db.Customers.Include(p => p.CustomerTags.Select(i => i.Tag.TagCategory));

There is also an overload of Include accepting the statement as a string:
var customers = db.Customers.Include("CustomerTags.Tag");



Article created: Aug 3 '15. Edited Aug 12 '15.

Your comment

You need to sign up / log in to comment this article

Author

Created by Robert Bengtsson [126] Aug 3 '15

Share article

Do you know about

Markdown?

Write an article