After much testing, I think that I have determined the exact scenario that has been causing us so much trouble.
Specifically, the problem involves Explicit loading of properties that are themselves base types. What seems to happen is that if you have the following classes:
public class Order : XPObject {…}
public class StandardOrder : Order {…}
public class RushedOrder : Order {…}
And then in another class you have the following reference:
public class Customer {
…
[ExplicitLoading]
public Order LastOrder {get; set; }
…
}
The effect of this, is that it efficiently loads all Customers and "correctly" left-join's in their last order. The problem occurs if some of the customers have RushedOrders. IN those cases, XPO then reaches BACK to the database, using an IN operator, to get all of the RushedOrder data for any records that are of that type.
So - the more specific question is - is there any way to not just MapInheritance to the parent table for sub-classes, but also to have it always "pre-load" the data from all child classes when loading the base class (so that it does NOT have to "reach back" to the database when child-types are encountered)?
Even doing 2 queries would be better (it seems to me). One query could (with the appropriate criteria - determine the XP-object types) so that the "get data" when loading the base class could also pre-load the data for the child types.
Thanks - and I look forward to hearing from you. Take care.
ps. The sample project demonstrates the issue. If you run SQL Profiler, you will see that it generates 2 SQL classes. By just changing the "LastOrder" property from an Order type (base type) to the specific type RushedOrder causes only 1 sql command to be executed.
Thanks again.