2
votes

I'm using EF4 with Self Tracking Entities T4 template.

When I perform a select on entity Page (with navigation property Category) like:

var page = (from p in context.Page select p).FirstOrDefault();

The navigation property Category is always null.

When I do it like this:

var page = (from p in context.Page.Include("Category") select p).FirstOrDefault();

The Category is loaded.

Why do I have to use the include function with a hardcoded string? Is it not possible to have EF4 automatically load the navigation property when I access it?

Or does that only work with EntityObjects and not STE?

1

1 Answers

1
votes

STE does not support lazy loading, only through context.LoadProperty. POCO + EntityObject do support it.

.Include is for eager loading, hopefully this method will be changed to support lambda expressions instead of hardcoded string.