本文整理汇总了C#中FluentMigrator.Expressions.CreateConstraintExpression类的典型用法代码示例。如果您正苦于以下问题:C# CreateConstraintExpression类的具体用法?C# CreateConstraintExpression怎么用?C# CreateConstraintExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateConstraintExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了CreateConstraintExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddingASingleColumnShouldAddItToToColumnList
public void AddingASingleColumnShouldAddItToToColumnList()
{
CreateConstraintExpression expression = new CreateConstraintExpression(ConstraintType.Unique);
CreateConstraintExpressionBuilder builder = new CreateConstraintExpressionBuilder(expression);
builder.OnTable("FOO").Column("BAR");
expression.Constraint.Columns.First().ShouldBe("BAR");
}
示例2: SettingTheTableNameSetsTheTableName
public void SettingTheTableNameSetsTheTableName()
{
CreateConstraintExpression expression = new CreateConstraintExpression(ConstraintType.Unique);
CreateConstraintExpressionBuilder builder = new CreateConstraintExpressionBuilder(expression);
builder.OnTable("FOO");
expression.Constraint.TableName.ShouldBe("FOO");
}
示例3: GetConstraintClusteringString
protected string GetConstraintClusteringString(CreateConstraintExpression constraint)
{
object indexType;
if (!constraint.Constraint.AdditionalFeatures.TryGetValue(
SqlServerExtensions.ConstraintType, out indexType)) return string.Empty;
return (indexType.Equals(SqlServerConstraintType.Clustered)) ? " CLUSTERED" : " NONCLUSTERED";
}
示例4: AddingMultipleColumnShouldAddThenToToColumnList
public void AddingMultipleColumnShouldAddThenToToColumnList()
{
CreateConstraintExpression expression = new CreateConstraintExpression(ConstraintType.Unique);
CreateConstraintExpressionBuilder builder = new CreateConstraintExpressionBuilder(expression);
builder.OnTable("FOO").Columns(new string[]{"BAR","BAZ" });
expression.Constraint.Columns.First().ShouldBe("BAR");
expression.Constraint.Columns.ElementAt(1).ShouldBe("BAZ");
}
示例5: ATableShouldBeAllowedToSpecifyASchema
public void ATableShouldBeAllowedToSpecifyASchema()
{
CreateConstraintExpression expression = new CreateConstraintExpression(ConstraintType.PrimaryKey);
CreateConstraintExpressionBuilder builder = new CreateConstraintExpressionBuilder(expression);
builder.OnTable("FOO").WithSchema("BAR").Column("BAZ");
expression.Constraint.SchemaName.ShouldBe("BAR");
expression.Constraint.TableName.ShouldBe("FOO");
expression.Constraint.Columns.First().ShouldBe("BAZ");
}
示例6: ErrorIsReturnedWhenHasNoColumns
public void ErrorIsReturnedWhenHasNoColumns()
{
var expression = new CreateConstraintExpression(ConstraintType.PrimaryKey)
{
Constraint =
{
TableName = "table1"
}
};
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.ConstraintMustHaveAtLeastOneColumn);
}
示例7: ErrorIsNotReturnedWhenTableNameIsSetAndHasAtLeastOneColumn
public void ErrorIsNotReturnedWhenTableNameIsSetAndHasAtLeastOneColumn()
{
var expression = new CreateConstraintExpression(ConstraintType.Unique)
{
Constraint =
{
TableName = "table1"
}
};
expression.Constraint.Columns.Add("column1");
var errors = ValidationHelper.CollectErrors(expression);
Assert.That(errors.Count, Is.EqualTo(0));
}
示例8: ErrorIsReturnedWhenTableNameIsEmptyString
public void ErrorIsReturnedWhenTableNameIsEmptyString()
{
var expression = new CreateConstraintExpression(ConstraintType.Unique)
{
Constraint =
{
TableName =
String.Empty
}
};
var errors = ValidationHelper.CollectErrors(expression);
errors.ShouldContain(ErrorMessages.TableNameCannotBeNullOrEmpty);
}
示例9: Generate
public override string Generate(CreateConstraintExpression expression)
{
var constraintType = (expression.Constraint.IsPrimaryKeyConstraint) ? "PRIMARY KEY" : "UNIQUE";
var constraintClustering = GetConstraintClusteringString(expression);
string columns = String.Join(", ", expression.Constraint.Columns.Select(x => Quoter.QuoteColumnName(x)).ToArray());
return string.Format(CreateConstraint, Quoter.QuoteTableName(expression.Constraint.TableName),
Quoter.Quote(expression.Constraint.ConstraintName),
constraintType,
constraintClustering,
columns);
}
示例10: Generate
public override string Generate(CreateConstraintExpression expression)
{
var constraintType = (expression.Constraint.IsPrimaryKeyConstraint) ? "PRIMARY KEY" : "UNIQUE";
string[] columns = new string[expression.Constraint.Columns.Count];
for (int i = 0; i < expression.Constraint.Columns.Count; i++) {
columns[i] = Quoter.QuoteColumnName(expression.Constraint.Columns.ElementAt(i));
}
return string.Format(CreateConstraint, Quoter.QuoteSchemaName(expression.Constraint.SchemaName), Quoter.QuoteTableName(expression.Constraint.TableName),
Quoter.Quote(expression.Constraint.ConstraintName),
constraintType,
String.Join(", ", columns));
}
示例11: UniqueConstraint
public ICreateConstraintOnTableSyntax UniqueConstraint()
{
var expression = new CreateConstraintExpression(ConstraintType.Unique);
_context.Expressions.Add(expression);
return new CreateConstraintExpressionBuilder(expression);
}
示例12: PrimaryKey
public Constraint.ICreateConstraintOnTableSyntax PrimaryKey(string primaryKeyName)
{
var expression = new CreateConstraintExpression(ConstraintType.PrimaryKey);
expression.Constraint.ConstraintName = primaryKeyName;
_context.Expressions.Add(expression);
return new CreateConstraintExpressionBuilder(expression);
}
示例13: GetCreateUniqueConstraintExpression
public static CreateConstraintExpression GetCreateUniqueConstraintExpression()
{
var expression = new CreateConstraintExpression(ConstraintType.Unique);
expression.Constraint.TableName = TestTableName1;
expression.Constraint.Columns.Add(TestColumnName1);
expression.ApplyConventions(new MigrationConventions());
return expression;
}
示例14: GetCreateNamedUniqueConstraintExpression
public static CreateConstraintExpression GetCreateNamedUniqueConstraintExpression()
{
var expression = new CreateConstraintExpression(ConstraintType.Unique);
expression.Constraint.TableName = TestTableName1;
expression.Constraint.Columns.Add(TestColumnName1);
expression.Constraint.ConstraintName = "TESTUNIQUECONSTRAINT";
return expression;
}
示例15: GetConstraintClusteringString
protected string GetConstraintClusteringString(CreateConstraintExpression constraint)
{
return string.Empty;
}