O'Reilly logo

Fluent Entity Framework by Rebecca M. Riordan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including related entities

Okay, so you’ve executed a query that loads all your recipes, and you know that you want to look at recipe ingredients. (And you know that you don’t want to make several bazillion trips to the server.) There are two possible situations: You might want to look at the ingredients of all the recipes, or you might want to only look at the ingredients of a selected recipe. The Entity Framework supports both scenarios. To include all the related entities in your query, you use the Include() method:

The Include() method allows you to load related entities when the query is executed:

Image

You can include multiple levels of relationships ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required