当前位置: 首页>>代码示例>>C#>>正文


C# Expressions.CreateConstraintExpression类代码示例

本文整理汇总了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");
        }
开发者ID:elfrostie,项目名称:fluentmigrator,代码行数:9,代码来源:CreateConstraintExpressionBuilderTests.cs

示例2: SettingTheTableNameSetsTheTableName

        public void SettingTheTableNameSetsTheTableName()
        {
            CreateConstraintExpression expression = new CreateConstraintExpression(ConstraintType.Unique);

            CreateConstraintExpressionBuilder builder = new CreateConstraintExpressionBuilder(expression);
            builder.OnTable("FOO");

            expression.Constraint.TableName.ShouldBe("FOO");
        }
开发者ID:elfrostie,项目名称:fluentmigrator,代码行数:9,代码来源:CreateConstraintExpressionBuilderTests.cs

示例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";
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:9,代码来源:SqlServer2000Generator.cs

示例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");
        }
开发者ID:elfrostie,项目名称:fluentmigrator,代码行数:10,代码来源:CreateConstraintExpressionBuilderTests.cs

示例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");
        }
开发者ID:elfrostie,项目名称:fluentmigrator,代码行数:11,代码来源:CreateConstraintExpressionBuilderTests.cs

示例6: ErrorIsReturnedWhenHasNoColumns

        public void ErrorIsReturnedWhenHasNoColumns()
        {
            var expression = new CreateConstraintExpression(ConstraintType.PrimaryKey)
            {
                Constraint =
                {
                    TableName = "table1"
                }
            };

            var errors = ValidationHelper.CollectErrors(expression);
            errors.ShouldContain(ErrorMessages.ConstraintMustHaveAtLeastOneColumn);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:13,代码来源:CreateConstraintExpressionTests.cs

示例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));
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:14,代码来源:CreateConstraintExpressionTests.cs

示例8: ErrorIsReturnedWhenTableNameIsEmptyString

        public void ErrorIsReturnedWhenTableNameIsEmptyString()
        {
            var expression = new CreateConstraintExpression(ConstraintType.Unique)
                                 {
                                     Constraint =
                                         {
                                             TableName =
                                                 String.Empty
                                         }
                                 };

            var errors = ValidationHelper.CollectErrors(expression);
            errors.ShouldContain(ErrorMessages.TableNameCannotBeNullOrEmpty);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:14,代码来源:CreateConstraintExpressionTests.cs

示例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);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:14,代码来源:SqlServer2000Generator.cs

示例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));
        }
开发者ID:elfrostie,项目名称:fluentmigrator,代码行数:15,代码来源:PostgresGenerator.cs

示例11: UniqueConstraint

 public ICreateConstraintOnTableSyntax UniqueConstraint()
 {
     var expression = new CreateConstraintExpression(ConstraintType.Unique);
     _context.Expressions.Add(expression);
     return new CreateConstraintExpressionBuilder(expression);
 }
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:6,代码来源:CreateExpressionRoot.cs

示例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);
 }
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:7,代码来源:CreateExpressionRoot.cs

示例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;
 }
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:8,代码来源:GeneratorTestHelper.cs

示例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;
 }
开发者ID:hazzik,项目名称:fluentmigrator,代码行数:8,代码来源:GeneratorTestHelper.cs

示例15: GetConstraintClusteringString

 protected string GetConstraintClusteringString(CreateConstraintExpression constraint)
 {
     return string.Empty;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:4,代码来源:SqlServerCeGenerator.cs


注:本文中的FluentMigrator.Expressions.CreateConstraintExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。