//public string QualifiedIdentifier //{ // get // { // return // (OrmObjectsDef != null && !string.IsNullOrEmpty(OrmObjectsDef.NS)) // ? OrmObjectsDef.NS + ":" + Identifier // : Identifier; // } //} private static EntityDescription MergeEntities(EntityDescription oldOne, EntityDescription newOne) { EntityDescription resultOne = new EntityDescription(newOne.Identifier, newOne.Name, newOne.Namespace, newOne.Description, newOne.OrmObjectsDef); //добавляем новые таблички foreach (TableDescription newTable in newOne.Tables) { resultOne.Tables.Add(newTable); } // добавляем новые проперти foreach (PropertyDescription newProperty in newOne.Properties) { PropertyDescription prop = newProperty.CloneSmart(); if (newOne.SuppressedProperties.Exists(delegate(PropertyDescription match) { return(match.Name == newProperty.Name); })) { prop.IsSuppressed = true; } resultOne.Properties.Add(prop); } foreach (PropertyDescription newProperty in newOne.SuppressedProperties) { PropertyDescription prop = newProperty.CloneSmart(); resultOne.SuppressedProperties.Add(prop); } if (oldOne != null) { // добавляем старые таблички, если нужно foreach (TableDescription oldTable in oldOne.Tables) { if (!resultOne.Tables.Exists(delegate(TableDescription tableMatch) { return(oldTable.Name == tableMatch.Name); })) { resultOne.Tables.Add(oldTable); } } foreach (PropertyDescription oldProperty in oldOne.SuppressedProperties) { PropertyDescription prop = oldProperty.CloneSmart(); resultOne.SuppressedProperties.Add(prop); } // добавляем старые проперти, если нужно foreach (PropertyDescription oldProperty in oldOne.Properties) { PropertyDescription newProperty = resultOne.GetProperty(oldProperty.Name); if (newProperty == null) { TableDescription newTable = resultOne.GetTable(oldProperty.Table.Identifier); TypeDescription newType = oldProperty.PropertyType; bool isSuppressed = resultOne.SuppressedProperties.Exists(delegate(PropertyDescription match) { return(match.Name == oldProperty.Name); }); bool isRefreshed = false; bool fromBase = true; if (newType.IsEntityType) { EntityDescription newEntity = resultOne.OrmObjectsDef.Entities.Find(delegate(EntityDescription matchEntity) { return(matchEntity.BaseEntity != null && matchEntity.BaseEntity.Identifier == newType.Entity.Identifier); }); if (newEntity != null) { newType = new TypeDescription(newType.Identifier, newEntity); isRefreshed = true; } } resultOne.Properties.Insert(resultOne.Properties.Count - newOne.Properties.Count, new PropertyDescription(resultOne, oldProperty.Name, oldProperty.PropertyAlias, oldProperty.Attributes, oldProperty.Description, newType, oldProperty.FieldName, newTable, fromBase, oldProperty.FieldAccessLevel, oldProperty.PropertyAccessLevel, isSuppressed, isRefreshed)); } } } return(resultOne); }