protected override SqlStatement ToSqlStatement(DbDialect dd, List<string> queryRequiredFields) { var sb = new StringBuilder("ALTER TABLE "); sb.Append(dd.QuoteForTableName(_from.MainTableName)); if(AddColumn != null) { sb.Append(" ADD "); sb.Append(dd.QuoteForColumnName(AddColumn.Key)); sb.Append(" "); sb.Append(dd.GetTypeName(AddColumn)); if(DefaultValue != null) { if (DefaultFirst) { sb.Append(" DEFAULT(").Append(DefaultValue).Append(")"); sb.Append(AddColumn.AllowNull ? " NULL" : " NOT NULL"); } else { sb.Append(AddColumn.AllowNull ? " NULL" : " NOT NULL"); sb.Append(" DEFAULT(").Append(DefaultValue).Append(")"); } } else { sb.Append(AddColumn.AllowNull ? " NULL" : " NOT NULL"); } sb.Append(";"); } return new SqlStatement(sb.ToString()); }
private void ProcessColumn(ColumnInfo ci, DbDialect dd) { string nullDefine = ci.AllowNull ? dd.NullString : dd.NotNullString; _sql.Append("\n\t"); _sql.Append(dd.QuoteForColumnName(ci.Key)); _sql.Append(" "); if (ci.IsDbGenerate && dd.IdentityTypeString != null) { _sql.Append(dd.IdentityTypeString); } else { _sql.Append(dd.GetTypeName(ci)); } if (ci.IsDbGenerate) { _sql.Append(" ").Append(dd.IdentityColumnString); } if (ci.IsKey) { ProcessKeyColumn(ci, dd, nullDefine); } else { _sql.Append(nullDefine); } _sql.Append(","); }