audiobird wrote:
Hi Otis!
Thanks for the respose
Employee, manager etc. are a great hierarchy to explain inheritance.
It is just a classic example
Next time I'll use shape->triangle->etc...
In the real life I have another types of entities.
The thing is... you might run into the fact to have to alter the type of a live object/entity: when an employee gets promoted to manager.
You are absolutely right. Employee can be promoted to manager (depends on his relations with another managers...
) However, lets say that in in my case employee or entity can't change its type.
It's good to use real data/names etc. for these kind of things. Now I have given you advice which doesn't fit your situation.
So I'd suggest in this case to use a Role like element: employee which has the role 'manager' is a manager.
By saying that, do you mean mean that there should be table tblRoles and tblEmploye should have Role_ID discriminator column and then it is TargetPerEntityHierarchy?
Changing a discriminator value is also changing a type so that's not useful. The way you should do it is to have a simple value with a lookup table (or if you use the numbers as enums in code, you can rely on that).
Lets say that I have several, derived from the base entities and all of them have the same fields like their base, but the difference is in the fields-on-relations.
How can I build such a model in LLBLGen?
If a subtype has a different relation, you have to define a table per entity, as the FK from the entity has to be placed in that subtype, not in the supertype (otherwise all entities inherit it). If the subtype entity is on the PK side, and you want to reference only that type from the FK side, you also need a different table for the subtype, otherwise it's not possible to determine which types to return if you fetch the related set.
Of course, I can put the inheritance on a side and not use it, but I think that inheritance will make my code more clearer and I can use polymorphism. As I understand from you, I should reference my base entity to all the possible collections (fields-on-relations) and in the code I should check what type of entity I'm dealing with (using Role_ID) and then decide if I can work with a particular referenced collection or not, but why is it better than inheritance?
Well, your situation doesn't run into the fact that you have to change the type of the entity, so I can't comment on that until I know what the real situation is.