开发者

EF4 Self tracking entities navigation property

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

When开发者_如何学Go 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜