void MappingEditor_TableRemoved(ArchAngel.Providers.EntityModel.Model.DatabaseLayer.ITable table) { BusyPopulating = true; bool changed = false; MappedTables.Remove(table); var mapping = Entity.Mappings().SingleOrDefault(m => m.FromTable == table); if (mapping != null) { mapping.Delete(); } if (MessageBox.Show(this, "Remove all entity properties that are mapped to this table's columns?", "Remove properties", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = Entity.Properties.Count() - 1; i >= 0; i--) { Property property = Entity.Properties.ElementAt(i); IColumn mappedColumn = property.MappedColumn(); if (mappedColumn != null && mappedColumn.Parent == table) { Entity.RemoveProperty(property); changed = true; } } } else { foreach (Property property in Entity.Properties) { IColumn mappedColumn = property.MappedColumn(); if (mappedColumn != null && mappedColumn.Parent == table) { property.SetMappedColumn(null); changed = true; } } } BusyPopulating = false; DrawEntityMappings(); if (changed || MappedTables.Count == 1) { PopulateEntityPropertyEditor(); } }
void MappingEditor_TableAdded(ArchAngel.Providers.EntityModel.Model.DatabaseLayer.ITable table) { MappedTables.Add(table); DrawEntityMappings(); PopulateEntityPropertyEditor(); }