Entity Framework 4 选择性延迟加载属性 [英] Entity Framework 4 selective lazy loading properties

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

问题描述

是否可以加载不包括某些属性的实体?该实体的属性之一是昂贵的选择.我想延迟加载此属性.这可能吗?

Is it possible to load an entity excluding some properties? One of this entity's properties is expensive to select. I would like to lazy load this property. Is that possible?

推荐答案

既然你已经看完了大家的回复,我就给你正确的答案.EF 不支持延迟加载属性.然而,它确实支持一个非常强大的概念.这称为表拆分,您可以在其中将一个表映射到两个实体.假设数据库中的产品表可以映射到产品实体和 ProductDetail 实体.然后,您可以将昂贵的字段移动到 ProductDetail 实体,然后在 prodcut 和 productdetail 实体之间创建 1..1 关联.然后,您可以仅在需要时延迟加载 productdetail 关联.在我的书的表演章节中,我有一个食谱叫做.13-9.将昂贵的财产转移到另一个实体

Now that you have read everyone's reply, I will give you the correct answer. EF does not support lazy loading of properties. However it does support a much powerful concept then this. It's called table splitting where you can map a table to two entities. Say a product table in the the database can be mapped to product entity and ProductDetail entity. You can then move the expensive fields to the ProductDetail entity and then create a 1..1 association between prodcut and productdetail entity. You can then lazy load the productdetail association only when you need it. In my performance chapter of my book, I have a recipe called. 13-9. Moving an Expensive Property to Another Entity

希望有帮助!

Julie Lerman 有一篇关于如何拆分表格

这篇关于Entity Framework 4 选择性延迟加载属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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