Entity Framework: How to disable lazy loading for specific query?

后端 未结 7 2157
夕颜
夕颜 2020-11-28 09:22

Is there any way to disable lazy loading for specific query on Entity Framework 6? I want to use it regularly, but sometimes I want to disable it. I\'m using virtual propert

7条回答
  •  情歌与酒
    2020-11-28 09:24

    Another approcah for another EF Version (Entity Framework 5)

    //Note: ContextOptions instead of ChangeTracker or Configuration
    context.ContextOptions.LazyLoadingEnabled = false; 
    

提交回复
热议问题