0

我在 Power Designer 中有一个实体对象并遍历它的继承,但我不知道如何获取子对象。有人可以发布示例代码吗?获取继承的对象 ID 也很重要。

编辑:基于帕斯卡示例的解决方案理念:

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 + ")");
  }
}
4

1 回答 1

1

以下是 VBScript 中的两个示例。它会让您了解您正在寻找的收藏品。第一个直接给出从实体继承的实体。

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

第二个示例枚举继承,以检索它们的子实体:

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

编辑:如果您的 PowerDesigner 版本没有.ChildEntities,您可以尝试通过将子实体与继承链接的 InheritanceLink:

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
于 2014-10-14T15:42:06.087 回答