/// <summary> /// 修改列。 /// </summary> /// <param name="command">当前命令。</param> /// <param name="builder">SQL语句构建实例。</param> protected override void Generate( AlterColumnCommand command, IndentedStringBuilder builder) { Check.NotNull(command, nameof(command)); Check.NotNull(builder, nameof(builder)); DropDefaultConstraint(command.Schema, command.Table, command.Name, builder); builder .Append("ALTER TABLE ") .Append(Sql.DelimitIdentifier(Prefix(command.Table), command.Schema)) .Append(" ALTER COLUMN "); ColumnDefinition( command.Schema, command.Table, command.Name, command.ClrType, command.ColumnType, command.IsNullable, /*identity:*/ false, /*defaultValue:*/ null, /*defaultValueSql:*/ null, command.ComputedColumnSql, command, builder); if (command.DefaultValue != null || command.DefaultValueSql != null) { builder .AppendLine(";") .Append("ALTER TABLE ") .Append(Sql.DelimitIdentifier(Prefix(command.Table), command.Schema)) .Append(" ADD"); DefaultValue(command.DefaultValue, command.DefaultValueSql, builder); builder .Append(" FOR ") .Append(Sql.DelimitIdentifier(command.Name)); } }
/// <summary> /// 修改列。 /// </summary> /// <param name="command">当前命令。</param> /// <param name="builder">SQL语句构建实例。</param> protected abstract void Generate(AlterColumnCommand command, IndentedStringBuilder builder);