예제 #1
0
 public void RunNameTransformation(INameTransformation nameTransform)
 {
     PrimaryKeyTable   = nameTransform.RenameObject(PrimaryKeyTable, "table");
     PrimaryKeyColumns = new List <IColumnReference>(PrimaryKeyColumns.MapEach(
                                                         c => (IColumnReference) new ColumnReference(nameTransform.RenameColumn(PrimaryKeyTable, c.ColumnName), c.SpecificData)
                                                         ));
 }
예제 #2
0
 public void RunNameTransformation(INameTransformation nameTransform)
 {
     FullName = nameTransform.RenameObject(FullName, "table");
     foreach (ColumnStructure col in Columns)
     {
         col.ColumnName = nameTransform.RenameColumn(FullName, col.ColumnName);
     }
     foreach (Constraint cnt in Constraints)
     {
         var col = cnt as ColumnsConstraint;
         if (col != null)
         {
             col.Columns = new List <IColumnReference>(col.Columns.MapEach(
                                                           c => (IColumnReference) new ColumnReference(nameTransform.RenameColumn(FullName, c.ColumnName), c.SpecificData)
                                                           ));
         }
         //cnt.Table = FullName;
         cnt.Name = nameTransform.RenameConstraint(cnt);
         var fk = cnt as ForeignKey;
         if (fk != null)
         {
             fk.RunNameTransformation(nameTransform);
         }
     }
 }
예제 #3
0
 public void RunNameTransformation(INameTransformation nameTransform)
 {
     FullName = nameTransform.RenameObject(FullName, "table");
     foreach (var col in Columns)
     {
         col.Name = nameTransform.RenameColumn(FullName, col.Name);
     }
     foreach (var cnt in Constraints)
     {
         cnt.ConstraintName = nameTransform.RenameConstraint(cnt);
     }
 }
예제 #4
0
        //public void AutoFillRefs()
        //{
        //    foreach (TableStructure tbl in Tables)
        //    {
        //        tbl._ReferencedFrom.Clear();
        //    }
        //    foreach (TableStructure src in Tables)
        //    {
        //        foreach (IForeignKey fk in src.GetConstraints<IForeignKey>())
        //        {
        //            try
        //            {
        //                TableStructure dst = (TableStructure)Tables[fk.PrimaryKeyTable];
        //                dst._ReferencedFrom.Add(new ForeignKey(fk));
        //            }
        //            catch
        //            {
        //                continue;
        //            }
        //        }
        //    }
        //}

        public void RunNameTransformation(INameTransformation nameTransform)
        {
            foreach (TableStructure tbl in Tables)
            {
                NameWithSchema newname = nameTransform.RenameObject(tbl.FullName, "table");;
                foreach (ColumnStructure col in tbl.Columns)
                {
                    string newcolname = nameTransform.RenameColumn(tbl.FullName, col.ColumnName);
                    col.ColumnName = newcolname;
                    if (col.Domain != null)
                    {
                        col.Domain = nameTransform.RenameObject(col.Domain, "domain");
                    }
                }
                tbl.FullName = nameTransform.RenameObject(tbl.FullName, "table");
            }
            foreach (DomainStructure dom in Domains)
            {
                dom.FullName = nameTransform.RenameObject(dom.FullName, "domain");
            }
            foreach (string objtype in SpecificObjects.Keys)
            {
                foreach (SpecificObjectStructure spec in SpecificObjects[objtype])
                {
                    NameWithSchema newname = nameTransform.RenameObject(spec.ObjectName, objtype);
                    spec.ObjectName = newname;
                    if (spec.RelatedTable != null)
                    {
                        spec.RelatedTable = nameTransform.RenameObject(spec.RelatedTable, "table");
                    }
                    if (spec.DependsOn != null)
                    {
                        foreach (var dep in spec.DependsOn)
                        {
                            dep.Name = nameTransform.RenameObject(dep.Name, dep.ObjectType);
                        }
                    }
                }
            }
            foreach (TableStructure tbl in Tables)
            {
                foreach (Constraint cnt in tbl.Constraints)
                {
                    NameWithSchema oldtable = cnt.Table.FullName;
                    //cnt.Table = nameTransform.RenameObject(cnt.Table, "table");
                    var col = cnt as ColumnsConstraint;
                    if (col != null)
                    {
                        for (int i = 0; i < col.Columns.Count; i++)
                        {
                            try
                            {
                                col.Columns[i] = new ColumnReference(nameTransform.RenameColumn(oldtable, col.Columns[i].ColumnName), col.Columns[i].SpecificData);
                            }
                            catch (KeyNotFoundException)
                            {
                                Logging.Warning("column {0}.{1} referenced but not exists", oldtable, col.Columns[i]);
                            }
                        }
                    }
                    var fk = cnt as ForeignKey;
                    if (fk != null)
                    {
                        for (int i = 0; i < fk.PrimaryKeyColumns.Count; i++)
                        {
                            try
                            {
                                fk.PrimaryKeyColumns[i] = new ColumnReference(
                                    nameTransform.RenameColumn(fk.PrimaryKeyTable, fk.PrimaryKeyColumns[i].ColumnName),
                                    fk.PrimaryKeyColumns[i].SpecificData);
                            }
                            catch (KeyNotFoundException)
                            {
                                Logging.Warning("column {0}.{1} referenced but not exists", fk.PrimaryKeyTable, fk.PrimaryKeyColumns[i]);
                            }
                        }
                        try
                        {
                            fk.PrimaryKeyTable = nameTransform.RenameObject(fk.PrimaryKeyTable, "table");
                        }
                        catch (KeyNotFoundException)
                        {
                            Logging.Warning("table {0} referenced but not exists", fk.PrimaryKeyTable);
                        }
                    }
                    cnt.Name = nameTransform.RenameConstraint(cnt);
                }
            }
        }
예제 #5
0
 public void RunNameTransformation(INameTransformation nameTransform)
 {
     FullName = nameTransform.RenameObject(FullName, "table");
     foreach (var col in Columns)
     {
         col.Name = nameTransform.RenameColumn(FullName, col.Name);
     }
     foreach (var cnt in Constraints)
     {
         cnt.ConstraintName = nameTransform.RenameConstraint(cnt);
     }
 }