1

I know I can disable the lazy loading by setup:

Configuration.LazyLoadingEnabled = false;

But I'm wondering does this setting affect every queries in the following? If so, are there any way to disable it for just one query?

Can I achieve this by just set Configuration.LazyLoadingEnabled = true after the query or are there any side effects on this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
joe morgan
  • 13
  • 4
  • Lazy Loading happens **after** a query has run though. If you eager-load (using `.Include()` or explicitly load additional data into the `DbContext` in subsequent queries) then there won't be a need for lazy-loading. (Also, methinks it's best-practice to always disable lazy-loading to ensure you don't accidentally run into performance issues (like the infamous "+1 problem") - not to mention we should avoiding doing any IO or heavy-lifting in a property-getter: property-getters should not have side-effects: https://wildermuth.com/2018/07/28/Avoid-Lazy-Loading-in-ASP-NET/ ) – Dai Aug 08 '22 at 04:17

0 Answers0