EF 4.1中非导航属性的延迟加载 [英] Lazy load for nonnavigation property in EF 4.1

查看:96
本文介绍了EF 4.1中非导航属性的延迟加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在EF 4.1中是否有一个简单的解决方案可以对非导航属性进行延迟加载?例如,对于字节数组.

Is there a simple solution to make lazy load for nonnavigation property in the EF 4.1? For example, for byte array.

推荐答案

没有EF不为标量和复杂属性提供延迟加载.诀窍是使用表拆分,其中将单个表中的数据映射到与一对一关系相关的两个实体中.一个实体是主体,它包含依赖项的导航属性,因此您可以使用延迟加载. 这是问题,其中包含链接的操作方法在EDMX中,答案提供了以代码优先进行映射的解决方案(注释包含MSDN论坛中另一个示例的链接).

No EF doesn't provide lazy loading for scalar and complex properties. The trick is to use table splitting where data from single table are mapped into two entities related with one-to-one relation. One entity is the principal and it contains navigation property to the dependent and because of that you can use lazy loading. Here is the question with link how to do it in EDMX and the answer provides solution for mapping in code-first (comments contains link to another example in MSDN forum).

这篇关于EF 4.1中非导航属性的延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆