Prefetches

There are cases where the developer knows in advance that he will iterate through all child objects of a given object. In this case it is possible to load the child objects in advance:

Employee.QueryHelper qh = new Employee.QueryHelper();

Query q = pm.NewQuery(typeof(Employee), condition, false);

q.Prefetches.Add(qh.travels);

This code loads all Travel objects together with the Employee objects matching the condition. Instead of loading each Travel object in a separate SQL query (which would be the default behavior) this query only needs two SQL queries. In NDO 2.0 you can prefetch a whole tree:

q.Prefetches.Add(qh.travels.expenses);

This code additionally loads all Expenses of all Travels of all Employees matching the condition.