|
I seem to be having some real trouble with the SQL being generated for my first major project using DevForce in C#. It's mandated that an inheritance hierarchy be used, with a common base entity class that contains a unique entity Id and various change tracking information, as well as a couple of intermediate base classes for differentiating between 'system' tables and standard tables (along with various extra properties).
Now, however, as I start adding tables to my EDMX and wiring up the inheritence, I'm starting to get problems with excessively large SQL being generated, which rapdily becomes an OutOfMemoryException as more tables are added. It seems to particularly manifest if I do an Include, to include a related table information, or do a standard Where query, as in 'BaseEntities.OfType<ChildClass>.Where(...)'.
What I can see from the SQL being generated, is that DevForce seems to be doing 'LEFT OUTER JOINS' from the base entity class to every since table defined in the model, which is obviously not what I want. With the 'Where' I'm explicitly telling it that I want objects of the given child class type, so I would have thought the generated SQL would be straight inner joins from the base entity class down through the intermediate class to the child class, and only then do left outer joins to any client classes (if any).
Likewise, for the Include, I had assumed that the fact that the navigation property points to the specific given table, that any generated query wouldn't need to be doing outer joins to other tables elsewhere in the model.
Is anyone aware of something I may be doing wrong in the setup of my model and/or project that could cause this? Or is there a way that DevForce is meant to be used when dealing with an inheritance hierarchy to avoid this? It's pretty much mandated that the base classes be there, so I'm hoping it's just something simple that I'm doing wrong, and won't have to do anything major to try and work around.
Any suggestions appreciated.
|