You are developing an order processing application that uses the ADO.NET Entity Framework against a SQL
Server database. Lazy loading has been disabled. The application displays orders and their associated order
details. Order details are filtered based on the category of the product in each order.
The Order class is shown below.

The OrderDetail class is shown below.

The Product class is shown below.

The Category class is shown below.

You need to return orders with their filtered list of order details included in a single round trip to the database.
Which code segment should you use?

Correct Answer: C
Explanation
Eager loading is the process whereby a query for one type of entity also loads related entities as part of the
query. Eager loading is achieved by use of the Include method. For example, the queries below will load blogs
and all the posts related to each blog.
using (var context = new BloggingContext())
{
// Load all blogs and related posts
var blogs1 = context.Blogs
Include(b => b.Posts)
ToList();
It is also possible to eagerly load multiple levels of related entities.
References: https://msdn.microsoft.com/en-us/library/jj574232(v=vs.113).aspx