public void RebuildRelationships() { SourceInfo.RebuildParentRelationships(); TargetInfo.RebuildParentRelationships(); if (SchemaItemMappings != null && SchemaItemMappings.Any()) { var allSchemaItems = new Dictionary <int, SchemaItem>(); FlattenSchemaItems(this.SourceInfo.Roots, allSchemaItems); FlattenSchemaItems(this.TargetInfo.Roots, allSchemaItems); foreach (var im in SchemaItemMappings) { if (im.SourceSchemaItemId != null) { im.SourceSchemaItem = allSchemaItems[im.SourceSchemaItemId.Value]; } im.TargetSchemaItem = allSchemaItems[im.TargetSchemaItemId]; } } }