Forum:  LLBLGen Pro Runtime Framework

Thread:  Collection property access causes lazy loading on new entity


ww (User)   Posted on: 06-Dec-2018 17:55:28.
Version 5.4, Self-Servicing.

Say I have entities Master and Detail, with a 1:M relationship. In MasterEntity, there's a Details property that returns the collection of related DetailEntities. With lazy loading enabled, this collection is fetched from the database the first time I access the Details property.

However, I've noticed that this happens even if the MasterEntity is new, even though there couldn't be any existing Details in the database (because of the FK restriction). When I'm adding a large number of MasterEntities, this produces a correspondingly-large number of unnecessary database calls.

Is there a way to avoid this, short of switching to self-servicing? Will setting AlreadyFetchedDetails do what I want?
Walaa (Support Team)   Posted on: 06-Dec-2018 18:06:01.
This is by design, as you can the PK-FK can be set to retrieve the related entities.

If this behavior is not what you want, you may want to turn off Lazy Loading.