问题描述
是否有可能加载不包括一些属性的实体?一本实体的属性是很昂贵的选择。我想延迟加载这个属性。这可能吗?
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不支持的属性的延迟加载。但是它支持更强大的概念,那么这个。这就是所谓的表拆分,您可以在一个表映射到两个实体。说,在数据库中的产品表可以被映射到产品实体和产品详情实体。然后,您可以将昂贵领域的产品详情实体,然后创建PRODCUT和产品详情实体之间的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
希望帮助!
这篇关于实体框架4选择延迟加载特性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!