Target per entity vs target per entity hierarchy

Posts   
 
    
Posts: 19
Joined: 27-Mar-2011
# Posted on: 05-Apr-2011 12:06:18   

When to use which approach.

My conclusions are (need confirmation ;-) ): 1. Selecting target per entity hierarchy is faster (no need for joins) 2. When working with entity of super class you can find out it's sub type through discriminator field with target per entity hierarchy (you can't do it with target per entity) 3. When you use target per entity hierarchy, sub type fields must be null.

Please let me know if there are some best practices document.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 05-Apr-2011 19:15:18   

1) Possibly, but it will depend on your entity hierarchy structure. With TPEH all of your data is in one big table which can lead to its own performance problems. This is something you will need to test and prove for yourself.

2) For both TPE and TPHE, super class entities are entities in their own right, so you always know what type they are.

3) True

I'm not sure we have a best practices document - as ever the choice is really only one that you can make for your self. In general, if your supertypes are fairly similar with a lot of common fields, and only a few differences then TPE may be a better choice. If they are quite different structurally, with only a few common fields, then TPEH may be the better choice as it will avoid having one table with a lot of NULLs in the unused fields.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 06-Apr-2011 11:04:48   

Using TPEH, subtype fields have to be null in the database. They don't have to be null in the entity. (You'll get a warning in the designer though, as it's not really useful)

Frans Bouma | Lead developer LLBLGen Pro
Posts: 19
Joined: 27-Mar-2011
# Posted on: 18-Apr-2011 10:24:26   

Thank you for answers, and sorry for my slow response.

Because type conversion from super type to sub type don't work (naturally), I have conclude that type check also don't work. But it does sunglasses

So, following code works perfectly.


if (superTypeObject is SubType)
{}