本文整理汇总了C#中FluentMigrator.Expressions.DeleteForeignKeyExpression类的典型用法代码示例。如果您正苦于以下问题:C# DeleteForeignKeyExpression类的具体用法?C# DeleteForeignKeyExpression怎么用?C# DeleteForeignKeyExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteForeignKeyExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了DeleteForeignKeyExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectValidationErrorsShouldReturnNoErrorsIfForeignTableNameAndForeignKeyNameAreSet
public void CollectValidationErrorsShouldReturnNoErrorsIfForeignTableNameAndForeignKeyNameAreSet()
{
var expression = new DeleteForeignKeyExpression { ForeignKey = new ForeignKeyDefinition { ForeignTable = "ForeignTable", Name = "FK"} };
var errors = ValidationHelper.CollectErrors(expression);
Assert.That(errors.Count, Is.EqualTo(0));
}
示例2: Delete_Foreign_Key_Should_Throw_Exception_If_Table_Name_Is_Null
public void Delete_Foreign_Key_Should_Throw_Exception_If_Table_Name_Is_Null()
{
// Setup empty FK
var deleteFKExpression = new DeleteForeignKeyExpression();
var fkDef = new ForeignKeyDefinition();
deleteFKExpression.ForeignKey = fkDef;
// Setup empty mock object
var mockGenerator = new MockGenerator(null, null, null);
Assert.Throws<ArgumentNullException>(() => mockGenerator.Generate(deleteFKExpression));
}
示例3: CollectValidationErrorsShouldReturnErrorsIfForeignColumnsAreSetButNotPrimaryTable
public void CollectValidationErrorsShouldReturnErrorsIfForeignColumnsAreSetButNotPrimaryTable()
{
var expression = new DeleteForeignKeyExpression
{
ForeignKey = new ForeignKeyDefinition
{
ForeignColumns = new Collection<string> { "User_id" },
ForeignTable = "UserRoles",
Name = "FK"
}
};
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.PrimaryTableNameCannotBeNullOrEmpty);
}
示例4: ReverseReturnsDeleteForeignKeyExpressionAfterApplyingConventions
public void ReverseReturnsDeleteForeignKeyExpressionAfterApplyingConventions()
{
var expression = new DeleteForeignKeyExpression
{
ForeignKey = new ForeignKeyDefinition
{
ForeignColumns = new Collection<string> { "User_id" },
ForeignTable = "UserRoles",
PrimaryColumns = new Collection<string> { "Id" },
PrimaryTable = "User",
}
};
expression.ApplyConventions(new MigrationConventions());
var reverse = expression.Reverse();
reverse.ShouldBeOfType<CreateForeignKeyExpression>();
}
示例5: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
truncator.Truncate(expression);
return base.Generate(expression);
}
示例6: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
if (expression.ForeignKey.ForeignTable == null)
throw new ArgumentNullException("Table name not specified, ensure you have appended the OnTable extension. Format should be Delete.ForeignKey(KeyName).OnTable(TableName)");
return string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.ForeignKey.ForeignTable), Quoter.QuoteColumnName(expression.ForeignKey.Name));
}
示例7: ForeignKey
public IDeleteForeignKeyFromTableSyntax ForeignKey()
{
var expression = new DeleteForeignKeyExpression();
_context.Expressions.Add(expression);
return new DeleteForeignKeyExpressionBuilder(expression);
}
示例8: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
return string.Format(DeleteConstraint, Quoter.QuoteTableName(expression.ForeignKey.ForeignTable), Quoter.QuoteColumnName(expression.ForeignKey.Name));
}
示例9: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
return string.Format("ALTER TABLE {0}.{1} DROP CONSTRAINT {2}", Quoter.QuoteSchemaName(expression.ForeignKey.ForeignTableSchema), Quoter.QuoteTableName(expression.ForeignKey.ForeignTable), Quoter.Quote(expression.ForeignKey.Name));
}
示例10: GetDeleteForeignKeyExpression
public static DeleteForeignKeyExpression GetDeleteForeignKeyExpression()
{
var expression = new DeleteForeignKeyExpression();
expression.ForeignKey.Name = "FK_Test";
expression.ForeignKey.ForeignTable = TestTableName1;
return expression;
}
示例11: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
return string.Format("ALTER TABLE {0}.{1} DROP CONSTRAINT {2}", FormatSchema(expression.ForeignKey.ForeignTableSchema), FormatIdentifier(expression.ForeignKey.ForeignTable), FormatIdentifier(expression.ForeignKey.Name));
}
示例12: Generate
public override string Generate(DeleteForeignKeyExpression expression)
{
throw new NotImplementedException();
}
示例13: CollectValidationErrorsShouldReturnErrorsIfForeignColumnsAreSetButNotPrimaryColumns
public void CollectValidationErrorsShouldReturnErrorsIfForeignColumnsAreSetButNotPrimaryColumns()
{
var expression = new DeleteForeignKeyExpression
{
ForeignKey = new ForeignKeyDefinition
{
ForeignColumns = new Collection<string> { "User_id" },
ForeignTable = "UserRoles",
PrimaryTable = "User",
Name = "FK"
}
};
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.ForeignKeyMustHaveOneOrMorePrimaryColumns);
}
示例14: CollectValidationErrorsShouldReturnErrorIfForeignTableNameIsNull
public void CollectValidationErrorsShouldReturnErrorIfForeignTableNameIsNull()
{
var expression = new DeleteForeignKeyExpression { ForeignKey = new ForeignKeyDefinition { ForeignTable = null } };
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.ForeignTableNameCannotBeNullOrEmpty);
}
示例15: ReverseSetsForeignTableAndForeignColumnsAndPrimaryTableAndPrimaryColumnsAOnGeneratedExpression
public void ReverseSetsForeignTableAndForeignColumnsAndPrimaryTableAndPrimaryColumnsAOnGeneratedExpression()
{
var expression = new DeleteForeignKeyExpression
{
ForeignKey = new ForeignKeyDefinition
{
ForeignColumns = new Collection<string> { "ForeignId" },
ForeignTable = "UserRoles",
PrimaryColumns = new Collection<string> { "PrimaryId" },
PrimaryTable = "User",
}
};
var reverse = expression.Reverse() as CreateForeignKeyExpression;
reverse.ForeignKey.ForeignTable.ShouldBe("User");
reverse.ForeignKey.PrimaryTable.ShouldBe("UserRoles");
reverse.ForeignKey.ForeignColumns.First().ShouldBe("PrimaryId");
reverse.ForeignKey.PrimaryColumns.First().ShouldBe("ForeignId");
}