Force loading all children of a list of records

Topics: Core, Troubleshooting, Writing modules
Sep 26, 2012 at 1:04 PM
Edited Sep 26, 2012 at 1:04 PM

I have a list of records that I loop through and I noticed that for evertime I accessed a child (also a record) it performs another query to fetch the data.

This is killing performance in our current usage case, and we're wondering how we can fetch a set of records and tell it to also fetch all / some 'child' data to prevent these kind of queries.

Any help would be greatly appreciated!

Sep 26, 2012 at 2:29 PM

I tried adding 'Aggregate' but that doesn't seem to help :/

More info: 

I query for a list of objects A that each has a list of object B.

I then loop over the List<B> and every 'loop' it triggers the query that fetches the 'B' data. I want to fetch the list of A objects AND eagerly load ALL B data in one query.

Anyone got a clue how to solve this?

FYI: These are 'custom' records (not content records).

Sep 30, 2012 at 9:46 PM

You can use QueryHint for that.

Sep 30, 2012 at 10:24 PM
Edited Sep 30, 2012 at 10:25 PM


Could you, or one of the members of the community, give us an example. Something practical [please, no theory].

Oct 1, 2012 at 12:46 AM

Search for it in the code. There are plenty of practical examples. One is in tags.