Try our conversational search powered by Generative AI!

How does EpiServer load data - Lazy or Eager Loading?

Vote:
 

When calling EpiServer's APIs, does it load all related entitties or does it enforce lazy loading?

For example

var rootCategory = _categoryRepository.GetRoot();

var subCategories = rootCategory.Categories; //Were these loaded in the previous call or are they loaded on this call?

Is there a way to make sure that all entities are loaded in the initial call?

Thanks in advance!

#255048
May 18, 2021 11:36
Vote:
 

Hi Sonya

In your case, the categories are loaded all-at-once and then cached. It happens in GetRoot(), either indirectly (if you call anything else than GetRoot) or directly (if you call it directly).

If you add, change or delete any category they are cleared from cache. Then you start over and all are reloaded next time one or more categories are needed. So it is pretty efficient.

#255055
May 18, 2021 13:57
Sonya - May 18, 2021 15:17
Thanks for this, really helps!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.