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

查看:102
本文介绍了实体框架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关联。然后,您可以在需要时加载产品详细信息关联。
在我的书的表演章节中,我有一个名叫的食谱。
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有一篇关于如何拆分表的文章

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

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