Inheritance Advice for Relations

Posts   
 
    
JRR avatar
JRR
User
Posts: 125
Joined: 07-Dec-2005
# Posted on: 26-Jan-2009 19:56:46   

I have a base entity:

  • Spawn

I have subTypes:

  • OrderSpawn
  • BlockSpawn
  • UnkownSpawn

I have entities related to the subTypes:

  • Order
  • Block

Finally, I have another entity that needs to have a reference to a spawn (any type)

  • Crop

My question is: How can I design this so each crop has 1 relation to a spawn (not 1 relation for each subtype = 3), and from that spawn, I can get the subtype, and then final entity related to that subtype (Order, block)?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Jan-2009 07:33:28   

Just add the Spawn->Crop relation to the base. Then construct the inheritance. You just did it once (with the parent), the subtypes will inherit that relation.

David Elizondo | LLBLGen Support Team
JRR avatar
JRR
User
Posts: 125
Joined: 07-Dec-2005
# Posted on: 28-Jan-2009 08:27:18   

So when I do this:

Crop --> Spawn

I have a spawn entity. The question is: what is the subtype of that spawn entity? And how can I find that type in C#? (using the determiner field method - TargetPerHeirarchy?)

Is there a clean way to do this in the LLBLGen entity framework?

JRR avatar
JRR
User
Posts: 125
Joined: 07-Dec-2005
# Posted on: 29-Jan-2009 21:04:39   

Wow - creating subtypes is really easy with relations. I see that the relation is mapped to the subtype as well.

The designer knew which sub types should have which relation, based upon which fields they inherited.

Impressive!