views:

100

answers:

2

I know this same question was asked for Entity Framework 1, but now that Entity Framework 4 has come out, and Microsoft claims that it provides all of the features of Linq to Sql + more, does Entity Framework now support lazy loading expensive properties? In Linq to Sql, this is extremely easy. There's a Delay Loaded option on any property (accessible through the Designer) that can simply be toggled on or off. Is there something similar in Entity Framework?

Thanks

A: 

Yes it does

http://geekswithblogs.net/iupdateable/archive/2009/11/26/getting-started-with-entity-framework-4-ndash-lazy-loading.aspx

Doobi
The example you sent is for lazy loading related entities. I'm looking for a way to lazy load certain properties in the same entity. It's very easy with Linq2Sql, but I haven't been able to find a way to do it in Entity Framework. The blog posts I've seen recommends that I separate the expensive fields into a separate table, that way, lazy loading will be doable, but having to change the database schema in order to support Entity Framework doesn't sound right.
JohnnyO
+1  A: 

I've asked the question here on the MS EF forum. As you see they provided a link to a description of Table splitting in Entity Framework.

Basically the idea is to split one database table into more than one Entity which are associated by 1:1 relationships and then benefit from the usual lazy loading feature between related entities.

Not as comfortable as the delayed-loading-flag in LINQ to SQL in my opinion but at least a solution which does not require to touch your database table.

Edit: Finally MS support answered in the thread I've linked above that a "Delayed loading flag" like in LINQ to SQL definitely doesn't exist in Entity Framework.

Slauma