Entity Framework 4 selective lazy loading properties

后端 未结 4 545
终归单人心
终归单人心 2020-11-30 07:47

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 possibl

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-30 08:04

    stimms is correct, but be careful while using lazy loading. You may have performance issues and not realize the property is getting loaded at a specific location in your code. This is because it loads the data when you use the property

    I prefer to use explicit loading. This way you know when they get loaded and where. Here's a link that gives an example for the LoadProperty http://sankarsan.wordpress.com/2010/05/09/ado-net-entity-framework-data-loading-part-2/

    You can also you Eager Loading by using the Include method. Example here:http://wildermuth.com/2008/12/28/Caution_when_Eager_Loading_in_the_Entity_Framework

提交回复
热议问题