public override void AssignFrom(IAbstractObjectStructure source) { base.AssignFrom(source); var dom = source as IDomainStructure; DataType = dom.DataType; }
public override void AssignFrom(IAbstractObjectStructure source) { base.AssignFrom(source); var cnt = source as IColumnsConstraint; Columns = ColumnReference.CopyList(cnt.Columns); }
internal void AddAlteredObject(IAbstractObjectStructure obj) { if (obj.GroupId != null) { alteredObjects.Add(obj.GroupId); } }
private void WantInfo() { if (m_anyObject != null) { return; } if (GroupId == null) { return; } m_srcObject = m_diff.FindSource(GroupId); m_dstObject = m_diff.FindTarget(GroupId); m_anyObject = m_srcObject ?? m_dstObject; Errors.CheckNotNull("DAE-00364", m_anyObject); m_srcName = m_srcObject != null?m_srcObject.GetName() : null; m_dstName = m_dstObject != null?m_dstObject.GetName() : null; var name = m_anyObject.GetName(); m_repr = SpecificRepresentationAddonType.Instance.TryFindRepresentation(name.ObjectType); if (m_repr != null) { m_typeImage = m_repr.Icon; } if (m_typeImage == null && name != null) { m_typeImage = Constraint.GetTypeBitmap(name.ObjectType); } if (m_typeImage == null && m_anyObject is IColumnStructure) { m_typeImage = CoreIcons.column; } }
public static List <IAbstractObjectStructure> GetAllObjects(this IAbstractObjectStructure obj) { var res = new List <IAbstractObjectStructure>(); obj.AddAllObjects(res); return(res); }
public override IDialectSpecificEditor GetSpecificEditor(IAbstractObjectStructure obj, IDatabaseSource db) { if (obj is IDatabaseStructure) { return(new MsSqlDatabaseEditor((IDatabaseStructure)obj, db)); } return(null); }
public static void CreateObject(this IDatabaseSource conn, IAbstractObjectStructure obj) { DatabaseStructure oldDb = new DatabaseStructure(); DatabaseStructure newDb = new DatabaseStructure(oldDb); newDb.AddObject(obj, true); conn.AlterDatabase(oldDb, newDb); }
//public virtual void NotifyChangeColumnType_RefsOnly(IColumnStructure newcol) { } //public bool IsFreezed { get { return m_isFreezed; } } //public IAbstractObjectStructure FreezeUntyped() //{ // if (IsFreezed) return this; // if (m_freezedCopy != null) return m_freezedCopy; // m_freezedCopy = (AbstractObjectStructure)CloneUntyped(); // m_freezedCopy.m_isFreezed = true; // return m_freezedCopy; //} //public abstract IAbstractObjectStructure CloneUntyped(); protected void CopyFromObject(IAbstractObjectStructure source) { // groupid is NOT merged m_specificData.Clear(); m_specificData.AddAll(source.SpecificData); Comment = source.Comment; XmlTool.CopyProperties(source, this); }
public override void AssignFrom(IAbstractObjectStructure source) { base.AssignFrom(source); var cnt = source as IConstraint; Name = cnt.Name; SpecificData.Clear(); SpecificData.AddAll(source.SpecificData); }
public override void AssignFrom(IAbstractObjectStructure obj) { base.AssignFrom(obj); var col = obj as IColumnStructure; Domain = col.Domain; DefaultValue = col.DefaultValue; DataType = col.DataType; }
public override void AssignFrom(IAbstractObjectStructure source) { base.AssignFrom(source); var obj = source as ISpecificObjectStructure; ObjectName = obj.ObjectName; ObjectType = obj.ObjectType; // CreateSql and SpecificDialect are merged using XmlTool.CopyProperties }
public static void DropObject(this IDatabaseSource conn, IAbstractObjectStructure obj) { DatabaseStructure oldDb = new DatabaseStructure(); oldDb.AddObject(obj, true); DatabaseStructure newDb = new DatabaseStructure(oldDb); newDb.DropObject(obj); conn.AlterDatabase(oldDb, newDb, DbDiffOptions.AlterStructureOptions()); }
public override void AssignFrom(IAbstractObjectStructure source) { base.AssignFrom(source); var fk = source as IForeignKey; OnUpdateAction = fk.OnUpdateAction; OnDeleteAction = fk.OnDeleteAction; PrimaryKeyTable = fk.PrimaryKeyTable; PrimaryKeyColumns = ColumnReference.CopyList(fk.PrimaryKeyColumns); }
public static void RenameObject(this IAlterProcessor proc, IAbstractObjectStructure obj, DbDiffOptions opts, NameWithSchema newName) { bool renameOk = false; var dom = obj as IDomainStructure; if (dom != null) { renameOk = DbDiffTool.GenerateRename(dom.FullName, newName, (old, sch) => proc.ChangeDomainSchema(old, sch), (old, nam) => proc.RenameDomain(old, nam), proc.AlterCaps.ChangeTableSchema, proc.AlterCaps.RenameDomain, opts); } var tbl = obj as ITableStructure; if (tbl != null) { renameOk = DbDiffTool.GenerateRename(tbl.FullName, newName, (old, sch) => proc.ChangeTableSchema(old, sch), (old, nam) => proc.RenameTable(old, nam), proc.AlterCaps.ChangeTableSchema, proc.AlterCaps.RenameTable, opts); } var col = obj as IColumnStructure; if (col != null) { if (proc.AlterCaps.RenameColumn) { proc.RenameColumn(col, newName.Name); renameOk = true; } } var cnt = obj as IConstraint; if (cnt != null) { if (proc.AlterCaps.RenameConstraint) { proc.RenameConstraint(cnt, newName.Name); renameOk = true; } } var spec = obj as ISpecificObjectStructure; if (spec != null) { renameOk = DbDiffTool.GenerateRenameSpecificObject(spec, newName, (old, sch) => proc.ChangeSpecificObjectSchema(old, sch), (old, nam) => proc.RenameSpecificObject(old, nam), proc.AlterCaps[spec.ObjectType].ChangeSchema, proc.AlterCaps[spec.ObjectType].Rename, opts); } if (!renameOk) { throw new AlterNotPossibleError(); } }
public static void ChangeObject(this IDatabaseSource conn, IAbstractObjectStructure oldObj, Action <AbstractObjectStructure> changeFunc) { DatabaseStructure oldDb = new DatabaseStructure(); oldDb.AddObject(oldObj, true); DatabaseStructure newDb = new DatabaseStructure(oldDb); AbstractObjectStructure newObj = (AbstractObjectStructure)newDb.FindByGroupId(oldObj); changeFunc(newObj); conn.AlterDatabase(oldDb, newDb, DbDiffOptions.AlterStructureOptions()); }
public override IDialectSpecificEditor GetSpecificEditor(IAbstractObjectStructure obj, IDatabaseSource db) { var tbl = obj as ITableStructure; if (tbl != null) { return(new MySqlTableEditor(tbl, db)); } var dbo = obj as IDatabaseStructure; if (dbo != null) { return(new MySqlDatabaseEditor(dbo, db)); } return(null); }
public static AbstractObjectStructure CloneObject(this IAbstractObjectStructure obj) { var tbl = obj as ITableStructure; if (tbl != null) { return(new TableStructure(tbl)); } var col = obj as IColumnStructure; if (col != null) { return(new ColumnStructure(col)); } var cnt = obj as IConstraint; if (cnt != null) { return(Constraint.CreateCopy(cnt)); } var spe = obj as ISpecificObjectStructure; if (spe != null) { return(new SpecificObjectStructure(spe)); } var sch = obj as ISchemaStructure; if (sch != null) { return(new SchemaStructure(sch)); } var dom = obj as IDomainStructure; if (dom != null) { return(new DomainStructure(dom)); } var dbs = obj as IDatabaseStructure; if (dbs != null) { return(new DatabaseStructure(dbs)); } return(null); }
public static void DropObject(this IAlterProcessor proc, IAbstractObjectStructure obj) { var tbl = obj as ITableStructure; if (tbl != null) { proc.DropTable(tbl); return; } var col = obj as IColumnStructure; if (col != null) { proc.DropColumn(col); return; } var cnt = obj as IConstraint; if (cnt != null) { proc.DropConstraint(cnt); return; } var spe = obj as ISpecificObjectStructure; if (spe != null) { proc.DropSpecificObject(spe); return; } var sch = obj as ISchemaStructure; if (sch != null) { proc.DropSchema(sch); return; } var dom = obj as IDomainStructure; if (dom != null) { proc.DropDomain(dom); return; } }
public static void ChangeObject(this IAlterProcessor proc, IAbstractObjectStructure obj, IAbstractObjectStructure newObj) { var tbl = obj as ITableStructure; if (tbl != null) { throw new AlterNotPossibleError(); } var col = obj as IColumnStructure; if (col != null) { proc.ChangeColumn(col, (IColumnStructure)newObj); return; } var cnt = obj as IConstraint; if (cnt != null) { proc.ChangeConstraint(cnt, (IConstraint)newObj); return; } var spe = obj as ISpecificObjectStructure; if (spe != null) { proc.ChangeSpecificObject(spe, (ISpecificObjectStructure)newObj); return; } var sch = obj as ISchemaStructure; if (sch != null) { proc.ChangeSchema(sch, (ISchemaStructure)newObj); return; } var dom = obj as IDomainStructure; if (dom != null) { proc.ChangeDomain(dom, (IDomainStructure)newObj); return; } }
public static void AlterObject(this IDatabaseSource conn, IAbstractObjectStructure oldObj, IAbstractObjectStructure newObj, DbDiffOptions options) { if (oldObj == null) { conn.CreateObject(newObj); return; } if (newObj == null) { conn.DropObject(oldObj); return; } if (oldObj.GroupId != newObj.GroupId) { throw new InternalError("DAE-00010 Altering object with different groupid"); } DatabaseStructure oldDb = new DatabaseStructure(); DatabaseStructure newDb = new DatabaseStructure(oldDb); oldDb.AddObject(oldObj, true); newDb.AddObject(newObj, true); conn.AlterDatabase(oldDb, newDb, options); }
public bool IsPaired(IAbstractObjectStructure obj) { return(srcGroupIds.ContainsKey(obj.GroupId) && dstGroupIds.ContainsKey(obj.GroupId)); }
public virtual IDialectSpecificEditor GetSpecificEditor(IAbstractObjectStructure obj, IDatabaseSource db) { return(null); }
protected AbstractObjectStructure(IAbstractObjectStructure src) { m_groupId = src.GroupId; }
public virtual void AssignFrom(IAbstractObjectStructure source) { CopyFromObject(source); }
public virtual void MergeFrom(IAbstractObjectStructure source) { AssignFrom(source); }
public void AddObject(IAbstractObjectStructure obj, bool reuseGrouId) { var col = obj as IColumnStructure; if (col != null) { var t = FindTable(col.Table.FullName); if (t == null) { t = AddTable(new TableStructure { FullName = col.Table.FullName }, true); } t.AddColumn(col, reuseGrouId); return; } var cnt = obj as IConstraint; if (cnt != null) { var t = FindTable(cnt.Table.FullName); if (t == null) { t = AddTable(new TableStructure { FullName = cnt.Table.FullName }, true); } var newcnt = Constraint.CreateCopy(cnt); if (!reuseGrouId) { newcnt.GroupId = Guid.NewGuid().ToString(); } t._Constraints.Add(newcnt); return; } var tbl = obj as ITableStructure; if (tbl != null) { AddTable(tbl, reuseGrouId); return; } var spe = obj as ISpecificObjectStructure; if (spe != null) { AddSpecificObject(spe, reuseGrouId); return; } var sch = obj as ISchemaStructure; if (sch != null) { AddSchema(sch, reuseGrouId); return; } var dom = obj as IDomainStructure; if (dom != null) { AddDomain(dom, reuseGrouId); return; } }
public static void ChangeObjectSchema(this IDatabaseSource conn, IAbstractObjectStructure oldObj, string newschema) { conn.ChangeObject(oldObj, obj => obj.SetObjectSchema(newschema)); }
public GenericCollection(IAbstractObjectStructure parent) { m_parent = parent; }
public GenericCollection_NameWithSchema(IAbstractObjectStructure parent) : base(parent) { }
public static void AlterObject(this IDatabaseSource conn, IAbstractObjectStructure oldObj, IAbstractObjectStructure newObj) { conn.AlterObject(oldObj, newObj, new DbDiffOptions()); }