开发者

Entity Framework 4 - Delay Loading Expensive Fields

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 Framew开发者_开发百科ork?

Thanks


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.


I tried the table splitting method. Works like a charm. Just create a second table with only a keyfield and a blob field, ono-to-one relation with the original image table. Delete de blob field from the image table.

Update the model and create the association between the image class and the blob class.

When you actualy need the blob field dont forget to "include" the blob table like this:

from a in dc.GeneralFile.include("Image").select(a => a.FileId, a.Image.Blob)  

Hope it works out for you.

P.S. Tried to add a picture, but am not allowed


Yes it does

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜