我在Power Designer中有一个实体对象并遍历其继承,但我不知道如何获取子对象。有人可以发布示例代码吗?获取继承的对象ID也很重要。
编辑:解决方案基于pascals示例的想法:
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 + ")");
}
}
答案 0 :(得分: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