通过imodel对象的Schemas属性,我们可以得到文件已有的所有schemas,示例代码如下:
foreach(Schema sch in imodel.Schemas)
{
strInfo += ("schemaName = " + sch.Name + "\n");
foreach (Class cl in sch.Classes)
{
strInfo += ("\tclass = " + cl.Name + "\n");
foreach (Property pr in cl.Properties)
{
strInfo += ("\t\tProperty = " + pr.CLRType.Name + " " + pr.Name + "\n");
}
foreach (Relationship rel in cl.Relationships)
{
strInfo += ("\t\trelationship = " + rel.Source.Name + "->" + rel.Target.Name + "\n");
}
}
foreach (string strRela in sch.Relationships)
{
strInfo += ("\tRelationship = " + strRela + "\n");
}
strInfo += ("\n\n");
}