Beispiel #1
0
        public void EditColumn(TableInfo tableInfo, ColumnInfo oldColumnInfo, ColumnInfo newColumnInfo, ICTransaction tran)
        {
            bool          isNew    = false;
            StringBuilder colQuery = new StringBuilder();

            colQuery.AppendLine(DropColumnConstraintSql(tableInfo, oldColumnInfo, tran));

            if (!newColumnInfo.ColumnName.Equals(oldColumnInfo.ColumnName) ||
                (!string.IsNullOrWhiteSpace(newColumnInfo.Remarks) && !newColumnInfo.Remarks.Equals(oldColumnInfo.Remarks)) ||
                (!string.IsNullOrWhiteSpace(oldColumnInfo.Remarks) && !oldColumnInfo.Remarks.Equals(newColumnInfo.Remarks)) ||
                newColumnInfo.MaxLength != oldColumnInfo.MaxLength)
            {
                if (oldColumnInfo.DBType == newColumnInfo.DBType)
                {
                    colQuery.AppendLine(EditColumnSql(tableInfo, oldColumnInfo, newColumnInfo));
                }
                else
                {
                    colQuery.AppendLine(AddColumnSql(tableInfo, newColumnInfo));
                    colQuery.AppendLine(AddColumnConstraintSql(tableInfo, newColumnInfo, tran));
                    isNew = true;
                }
            }
            else if (oldColumnInfo.DBType != newColumnInfo.DBType)
            {
                ColumnInfo changeNameColInfo = ObjectFactory.Clone <ColumnInfo>(oldColumnInfo);
                changeNameColInfo.ColumnName += "_" + DateTime.Now.ToString("yyyyMMddHHmmss");
                colQuery.AppendLine(EditColumnSql(tableInfo, oldColumnInfo, changeNameColInfo));
                colQuery.AppendLine(AddColumnSql(tableInfo, newColumnInfo));
                colQuery.AppendLine(AddColumnConstraintSql(tableInfo, newColumnInfo, tran));
                isNew = true;
            }

            if (!isNew)
            {
                colQuery.AppendLine(AddColumnConstraintSql(tableInfo, newColumnInfo, tran));
            }

            if (tran == null)
            {
                MySqlHelper.ExecuteNonQuery(this.CurrentConnectionString, colQuery.ToString());
            }
            else
            {
                MySqlHelper.ExecuteNonQuery((MySqlConnection)tran.Connection, colQuery.ToString());
            }
        }
Beispiel #2
0
 /// <summary>
 /// 克隆一份Searcher对象
 /// </summary>
 /// <returns></returns>
 public virtual Searcher Clone()
 {
     return(ObjectFactory.Clone(this));
 }
Beispiel #3
0
 /// <summary>
 /// 克隆分组对象
 /// </summary>
 /// <returns>返回克隆后的分组对象</returns>
 public ConditionGroup Clone()
 {
     return(ObjectFactory.Clone <ConditionGroup>(this));
 }