Inheritance, controlling LEFT JOINs

Posts   
 
    
nottinbe
User
Posts: 46
Joined: 15-Mar-2007
# Posted on: 04-Nov-2009 17:24:18   

Using LLGLGen 2.6.8 with SQL Server 2008 and .NET 3.5.

I am using in heritance with a single base table and many tables derived from the base. There is only one layer of inheritance.

For example:

OrderEntity OrderAEntity OrderBEntity OrderCEntity etc.

I understand why the LEFT JOINs to the derived tables are generated when fetching an order. However, at any given time (but it can change at runtime) I know that certain derived tables will never have data. So for example I may know than only OrderA entities exist.

Is there any way to tell LLGLgen to pretend as if certain derived tables do not exist and not consider them in the inheritance relationships and field selections?

Thanks,

Brian

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 04-Nov-2009 17:39:41   
nottinbe
User
Posts: 46
Joined: 15-Mar-2007
# Posted on: 04-Nov-2009 17:57:16   

Hi Walla,

That is not what I was asking for. Your solution still generates a query that has LEFT JOINs to OrderA OrderB and OrderC. With an added EntityType Filter for say "OrderB", it just filters out the results to those that are of type OrderB.

This is basically the inverse of what I am asking.

For example, I may KNOW there exists data only in OrderB. I don't need to filter on it - as I know for a fact that no data exists in OrderA or OrderC. What I want is to eliminate the LEFT JOINs to OrderA and OrderC.

Thanks, Brian

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 04-Nov-2009 18:55:29   

you can't control this as the query you execute asks for a supertyped type and the code doesn't know which tables don't contain a row.

In general, don't overdo inheritance: it might look great, but it is a performance hit in the database. Often inheritance isn't really needed, as the hierarchy is really a set of entities which are all a different role, or don't differ that much.

Frans Bouma | Lead developer LLBLGen Pro
nottinbe
User
Posts: 46
Joined: 15-Mar-2007
# Posted on: 05-Nov-2009 15:38:31   

I know the LLBLGen framework can't know which tables have no rows... but my code does. I got this working by deriving from InheritanceInfoProviderCore and overridding GetHierarchyFields and GetHierarchyRelations.

Thanks, Brian