private static void ConvertTableAutoId2Id(CloneTableDefInfo tableInfo, IList <CloneTableDefInfo> tableList)
        {
            CloneTableFieldDefInfo       m_XID           = tableInfo.AutoIncrementColumn();
            CloneIndexDefInfo            m_XPK           = tableInfo.IndexPK();
            IList <CloneRelationDefInfo> tableToRelation = tableInfo.ForeignRelations(tableList);

            if (m_XID == null)
            {
                tableInfo.CreateTargetFAUTO(COLUMN_NAME_AUTOID, DBConstants.DB_LONG);

                tableInfo.CreateTargetIndexFromXPK(m_XPK);

                m_XPK = tableInfo.CreatePKAutoConstraint("XPK", COLUMN_NAME_AUTOID);
            }
            else
            {
                string oldAuroName = m_XID.TargetName();

                m_XID.ReNameTargetColumn(COLUMN_NAME_AUTOID);

                foreach (var index in tableInfo.IndexesNonPK())
                {
                    index.ReNameTargetColumn(oldAuroName, COLUMN_NAME_AUTOID);
                }

                foreach (var relationTable in tableToRelation)
                {
                    relationTable.ReNameTableColumn(oldAuroName, COLUMN_NAME_AUTOID);
                }

                tableInfo.CreateTargetIndexFromXPK(m_XPK, oldAuroName, COLUMN_NAME_AUTOID);

                m_XPK = tableInfo.CreatePKAutoConstraint("XPK", COLUMN_NAME_AUTOID);
            }
        }
 private IndexDefInfo CloneTargetIndex(CloneIndexDefInfo defInfo)
 {
     if (defInfo == null)
     {
         return(null);
     }
     return(defInfo.GetTargetInfo());
 }
 private IndexDefInfo CloneSourceIndex(CloneIndexDefInfo defInfo)
 {
     if (defInfo == null)
     {
         return(null);
     }
     return(defInfo.GetSourceInfo());
 }
        public CloneIndexDefInfo CreatePKAutoConstraint(string lpszName, string lpszIdName)
        {
            string constraintName = lpszName + m_strName;

            m_PKConstraint = new CloneIndexDefInfo(constraintName, m_strName, true);
            m_PKConstraint.AppendTargetField(lpszIdName);

            return(m_PKConstraint);
        }
Beispiel #5
0
        public object Clone()
        {
            CloneIndexDefInfo other = (CloneIndexDefInfo)this.MemberwiseClone();

            other.m_IndexFields = this.m_IndexFields.Select((idxf) => ((CloneIndexFieldDefInfo)idxf.Clone())).ToList();
            other.m_strName     = this.m_strName;
            other.m_strTable    = this.m_strTable;
            other.m_nFields     = this.m_nFields;
            other.m_bUnique     = this.m_bUnique;
            other.m_bPrimary    = this.m_bPrimary;

            return(other);
        }
 public CloneTableDefInfo(TableDefInfo defInfo, UInt32 versCreate)
 {
     this.m_TableFields    = defInfo.TableColumns().Select((tf) => new CloneTableFieldDefInfo(tf)).ToList();
     this.m_PKConstraint   = CloneIndex(defInfo.IndexPK());
     this.m_AKConstraint   = CloneIndex(defInfo.IndexAK());
     this.m_TableIndexs    = defInfo.IndexesNonPK().Select((idx) => new CloneIndexDefInfo(idx)).ToList();
     this.m_TableRelations = defInfo.Relations().Select((rel) => new CloneRelationDefInfo(rel)).ToList();
     this.m_nFields        = defInfo.FieldsCount();
     this.m_strOwnerName   = defInfo.OwnerName();
     this.m_strUsersName   = defInfo.UsersName();
     this.m_strName        = defInfo.TableName();
     this.m_VersFrom       = defInfo.VersFrom();
     this.m_VersDrop       = defInfo.VersDrop();
     this.m_VersCreate     = versCreate;
 }
        public void CreateTargetIndexFromXPK(CloneIndexDefInfo primaryKey)
        {
            if (primaryKey != null)
            {
                IndexDefInfo indexInfo = (IndexDefInfo)primaryKey.GetTargetInfo();

                string indexName = indexInfo.m_strName.Replace("XPK", "XAK");

                indexInfo.m_strName = indexName;

                indexInfo.m_bPrimary = false;

                indexInfo.m_bUnique = true;

                CloneIndexDefInfo indexClone = new CloneIndexDefInfo(null, indexInfo);

                IndexAppend(indexClone);
            }
        }
        public CloneIndexDefInfo CreateTargetIndexFromXPK(CloneIndexDefInfo pkConstraint, string oldAutoName, string newAutoName)
        {
            m_AKConstraint = null;

            if (pkConstraint != null)
            {
                IndexDefInfo indexInfo = (IndexDefInfo)pkConstraint.GetTargetInfo();

                m_AKConstraint = new CloneIndexDefInfo(null, indexInfo);

                string indexName = m_AKConstraint.m_strName.Replace("XPK", "XAK");

                m_AKConstraint.m_strName = indexName;

                m_AKConstraint.m_bPrimary = false;

                m_AKConstraint.m_bUnique = true;

                m_AKConstraint.ReNameTargetColumn(oldAutoName, newAutoName);
            }
            return(m_AKConstraint);
        }
        public CloneIndexDefInfo IndexAppend(CloneIndexDefInfo indexInfo)
        {
            m_TableIndexs.Add(indexInfo);

            return(indexInfo);
        }