I have following model:
A
1
|
*
B
^ ^
| |
B1 B2
where B is an abstract superclass of B1 and B2. I now have a PSQuery like:
var data = es.PSQuery<A>().Where(..).SelectMany(x => x.Bs).ToList();
The generated SQL looks like following:
SELECT ALIAS.ID FROM B ALIAS WHERE ....
Then MDriven gets all discriminators in chunks to determine the type of the objects, so these can be quite some SQLs:
SELECT ALIAS.ID, ALIAS.DISCRIMINATOR FROM B ALIAS WHERE ID in (?, ? ....)
Now MDriven knows the types and can load the data. This process all in all takes much longer than a handmade SQL. So my questions are:
- Can I get the SQL from a PSQuery so that I can execute it by myself? In this case I build up a quite complicated expression and I really prefer building up the PSQuery to building the SQL string.
- If MDriven would load the descriminator in the first SQL, the deferred loading would not be necessary. We use a custom OR-Mapping for this table. Is it possible to include the discriminator into the first SQL?
- Is there a different hint to prevent this time consuming load behaviour (keeping the model unchanged)?