0

I have an entity object in Power Designer and walk through its inheritances but I do not know how to get the child object. Could someone post an example code? It is also important to get the Object ID of the inheritance.

Edit: solution Idea based on pascals examples:

foreach (PdCDM.Inheritance curPDInheritance in curPDEntity.InheritedBy){
  foreach(PdCDM.InheritanceLink curPDInheritanceLink in curPDInheritance.InheritanceLinks){
    Console.WriteLine(curPDEntity.Name + " parent of " + ((PdCDM.Entity)curPDInheritanceLink.ChildEntity).Name+ " through " + curPDInheritance.Name + " (" + curPDInheritance.ObjectID + ")");
  }
}
user2722077
  • 462
  • 1
  • 8
  • 21

1 Answers1

1

Here are two examples in VBScript. It will give you an idea of the collections you're looking for. The first one directly gives the entities inheriting from the an entity.

option explicit
dim mdl : set mdl = ActiveModel
dim ent,chl
for each ent in mdl.Entities
   for each chl in ent.InheritedByEntities
      output ent.Name + " parent of " + chl.Name
   next
next

The second example enumerates the inheritances, to retrieve their child entities:

option explicit
dim mdl : set mdl = ActiveModel
dim ent,inh,chl
for each ent in mdl.Entities
   for each inh in ent.InheritedBy
      for each chl in inh.ChildEntities
         output ent.Name + " parent of " + chl.Name + " through " + inh.Name + " (" + inh.ObjectID + ")"
      next
   next
next

EDIT: if your version of PowerDesigner does not have .ChildEntities, you can try through the InheritanceLink which links the child entity, with the inheritance:

option explicit
dim mdl : set mdl = ActiveModel
dim ent,inh,ilk
for each ent in mdl.Entities
   for each inh in ent.InheritedBy
      for each ilk in inh.InheritanceLinks
         output ent.Name + " parent of " + ilk.Object2.Name + " through " + inh.Name + " (" + inh.ObjectID + ")"
      next
   next
next
pascal
  • 3,287
  • 1
  • 17
  • 35