开发者

Entity Framework VarBinary defer

I am switching over from Linq-To-Sql to the Entity Framework. Before when I was in the modeler and added a database object with say a Image or VarBinary property I could set the defer loading of that field so that 开发者_JAVA百科when i got a single instance of an db object it would not pull down all that binary data until I accessed the property. I am using the .net 3.5 Entity dll's


This is not directly possible in EF. You must use mapping called table splitting. It means that you will divide your table in two entities in 1:1 relation (entities share only primary key). First entity will have all fields except binary data and second entity will have only Id and binary data. This will create navigation properties. Now you can load first entity and lazy load binary data when you access navigation property pointing to second entity.

Here you have example for EFv1 where you must modify EDMX directly (as XML) and here is example for EFv4 which should allow this mapping directly in designer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜