public override void Generate(DropDefaultConstraintOperation dropDefaultConstraintOperation, IndentedStringBuilder stringBuilder) { Check.NotNull(dropDefaultConstraintOperation, "dropDefaultConstraintOperation"); Check.NotNull(stringBuilder, "stringBuilder"); var constraintNameVariable = "@var" + _variableCount++; stringBuilder .Append("DECLARE ") .Append(constraintNameVariable) .AppendLine(" nvarchar(128)"); stringBuilder .Append("SELECT ") .Append(constraintNameVariable) .Append(" = name FROM sys.default_constraints WHERE parent_object_id = OBJECT_ID(N") .Append(DelimitLiteral(dropDefaultConstraintOperation.TableName)) .Append(") AND COL_NAME(parent_object_id, parent_column_id) = N") .AppendLine(DelimitLiteral(dropDefaultConstraintOperation.ColumnName)); stringBuilder .Append("EXECUTE('ALTER TABLE ") .Append(DelimitIdentifier(dropDefaultConstraintOperation.TableName)) .Append(" DROP CONSTRAINT \"' + ") .Append(constraintNameVariable) .Append(" + '\"')"); }
public void Create_and_initialize_operation() { var dropDefaultConstraintOperation = new DropDefaultConstraintOperation("dbo.MyTable", "Foo"); Assert.Equal("dbo.MyTable", dropDefaultConstraintOperation.TableName); Assert.Equal("Foo", dropDefaultConstraintOperation.ColumnName); Assert.False(dropDefaultConstraintOperation.IsDestructiveChange); }
public void Dispatches_visitor() { var dropDefaultConstraintOperation = new DropDefaultConstraintOperation("dbo.MyTable", "Foo"); var mockVisitor = new Mock<MigrationOperationSqlGenerator>(new RelationalTypeMapper()); var builder = new Mock<IndentedStringBuilder>(); dropDefaultConstraintOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(dropDefaultConstraintOperation, builder.Object), Times.Once()); }
public virtual void Visit([NotNull] DropDefaultConstraintOperation dropDefaultConstraintOperation, [NotNull] TContext context) { VisitDefault(dropDefaultConstraintOperation, context); }
public override void Generate( DropDefaultConstraintOperation dropDefaultConstraintOperation, IndentedStringBuilder stringBuilder) { // TODO: Rebuild table throw new NotImplementedException(); }