Entity Framework Eager Loading Multi Levels, Without String

This is one way to do Eager Loading:

dim Q = from o in contex.Orders.Include("Items").Include("Items.Products")

I want to do that without using Strings.

With one level it's easy:

dim Q = from o in contex.Orders.Include(Function(x) x.Items)

But how do you do the include to include Items.Products?

Upvotes: 0

Views: 1192

Answers (1)

csherriff
csherriff

Reputation: 113

EF5 Strings

New to EF5 are named include parameters.

Muliple include levels

You can include multiple child level eager fetches using the following syntax

var orders = db.Orders.Include(a => a.Items.Select(c => c.Products));

Upvotes: 2

Related Questions