且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架4选择性延迟加载属性

更新时间:2021-07-14 22:15:53

现在你已经阅读了所有人的回复,我会给你正确的答案。 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有一篇关于如何拆分表的文章