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


C# Expressions.CreateTableExpression类代码示例

本文整理汇总了C#中FluentMigrator.Expressions.CreateTableExpression的典型用法代码示例。如果您正苦于以下问题:C# CreateTableExpression类的具体用法?C# CreateTableExpression怎么用?C# CreateTableExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CreateTableExpression类属于FluentMigrator.Expressions命名空间,在下文中一共展示了CreateTableExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCreateTableWithAutoIncrementExpression

 public static CreateTableExpression GetCreateTableWithAutoIncrementExpression()
 {
     var expression = new CreateTableExpression { TableName = TestTableName1 };
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsIdentity = true, Type = DbType.Int32 });
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
     return expression;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs

示例2: GetCreateTableExpression

 public static CreateTableExpression GetCreateTableExpression()
 {
     CreateTableExpression expression = new CreateTableExpression() { TableName = TestTableName1, };
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, Type = DbType.String });
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
     return expression;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs

示例3: ErrorIsReturnedWhenTableNameIsEmptyString

        public void ErrorIsReturnedWhenTableNameIsEmptyString()
        {
            var expression = new CreateTableExpression { TableName = String.Empty };

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

示例4: CanMigrateTableWithIdentityData

        public void CanMigrateTableWithIdentityData()
        {
            // Arrange
              var create = new CreateTableExpression
              {
              TableName = "Foo"
             ,
              Columns = new List<ColumnDefinition> { new ColumnDefinition { Name = "Id", Type = DbType.Int32, IsIdentity = true} }
              };
              var context = GetDefaultContext();

              var insert = new InsertDataExpression()
              {
              TableName = "Foo"
              };
              insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 1)});
              insert.Rows.Add(new InsertionDataDefinition { new KeyValuePair<string, object>("Id", 100) });
              insert.WithIdentity = true;

              // Act
              MigrateTable(context, create, insert);

              // Assert
              context.MigrationIndex.ShouldBe(1);
        }
开发者ID:garchibald,项目名称:fluentmigrator,代码行数:25,代码来源:SqlServerMigrationTests.cs

示例5: ErrorIsNotReturnedWhenTableNameIsSet

        public void ErrorIsNotReturnedWhenTableNameIsSet()
        {
            var expression = new CreateTableExpression { TableName = "table1" };

            var errors = ValidationHelper.CollectErrors(expression);
            Assert.That(errors.Count, Is.EqualTo(0));
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:CreateTableExpressionTests.cs

示例6: GetCreateTableWithNullableColumn

 public static CreateTableExpression GetCreateTableWithNullableColumn()
 {
     var expression = new CreateTableExpression { TableName = TestTableName1 };
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsNullable = true, Type = DbType.String });
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32 });
     return expression;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs

示例7: Generate

        public string Generate(CreateTableExpression expression)
        {
            IList<ColumnDefinition> columns = expression.Columns;
            string result = "";
            int total = columns.Count - 1;

            //if more than one column is a primary key or the primary key is given a name, then it needs to be added separately
            IList<ColumnDefinition> primaryKeyColumns = GetPrimaryKeyColumns(columns);
            bool addPrimaryKeySeparately = false;
            if (primaryKeyColumns.Count > 1 || (primaryKeyColumns.Count == 1 && !string.IsNullOrEmpty(primaryKeyColumns[0].PrimaryKeyName)))
            {
                if(CanSeperatePrimaryKeyAndIdentity || primaryKeyColumns.All(x => !x.IsIdentity))
                {
                    addPrimaryKeySeparately = true;
                    foreach (ColumnDefinition column in primaryKeyColumns)
                    {
                        column.IsPrimaryKey = false;
                    }
                }
            }

            for (int i = 0; i < columns.Count; i++)
            {
                result += Generate(columns[i]);

                if (i != total)
                    result += ", ";
            }

            if (addPrimaryKeySeparately)
                result = AddPrimaryKeyConstraint(expression.TableName, primaryKeyColumns, result);

            return result;
        }
开发者ID:Ang3lFir3,项目名称:fluentmigrator,代码行数:34,代码来源:ColumnBase.cs

示例8: GetCreateTableWithNamedMultiColumnPrimaryKeyExpression

 public static CreateTableExpression GetCreateTableWithNamedMultiColumnPrimaryKeyExpression()
 {
     var expression = new CreateTableExpression { TableName = TestTableName1 };
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, IsPrimaryKey = true, PrimaryKeyName = "TestKey", Type = DbType.String });
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32, IsPrimaryKey = true });
     return expression;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs

示例9: GetCreateTableWithDefaultValue

 public static CreateTableExpression GetCreateTableWithDefaultValue()
 {
     CreateTableExpression expression = new CreateTableExpression() { TableName = TestTableName1, };
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName1, Type = DbType.String, DefaultValue = "Default", TableName = TestTableName1 });
     expression.Columns.Add(new ColumnDefinition { Name = TestColumnName2, Type = DbType.Int32, DefaultValue = 0, TableName = TestTableName1 });
     return expression;
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:GeneratorTestHelper.cs

示例10: GetCreateTableExpression

        private CreateTableExpression GetCreateTableExpression(string tableName)
        {
            var columnName1 = "ColumnName1";

            var column1 = new ColumnDefinition { Name = columnName1, Type = DbType.String };

            var expression = new CreateTableExpression { TableName = tableName };
            expression.Columns.Add(column1);
            return expression;
        }
开发者ID:gliljas,项目名称:fluentmigrator,代码行数:10,代码来源:SqlServer2008GeneratorTests.cs

示例11: CreateTableMigration

        public dynamic CreateTableMigration(CreateTableMigration createTableMigration)
        {
            var create_table_expr = new CreateTableExpression
                                        {
                                            TableName = createTableMigration.TableName,
                                            SchemaName = createTableMigration.SchemaName,
                                        };
            create_table_expr.Columns = createTableMigration.Colunns.Select(build_column_definition).ToList();

            return create_table_expr;
        }
开发者ID:jcteague,项目名称:SchemaMigrator,代码行数:11,代码来源:FluentMigratorMigrationFactory.cs

示例12: CanCreateTableWithDateTimeOffsetColumn

        public void CanCreateTableWithDateTimeOffsetColumn()
        {
            var expression = new CreateTableExpression {TableName = "TestTable1"};
            expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn1", Type = DbType.DateTimeOffset});
            expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn2", Type = DbType.DateTime2});
            expression.Columns.Add(new ColumnDefinition {TableName = "TestTable1", Name = "TestColumn3", Type = DbType.Date});
            expression.Columns.Add(new ColumnDefinition { TableName = "TestTable1", Name = "TestColumn4", Type = DbType.Time });

            var result = Generator.Generate(expression);
            result.ShouldBe("CREATE TABLE [dbo].[TestTable1] ([TestColumn1] DATETIMEOFFSET NOT NULL, [TestColumn2] DATETIME2 NOT NULL, [TestColumn3] DATE NOT NULL, [TestColumn4] TIME NOT NULL)");
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:11,代码来源:SqlServer2008GeneratorTests.cs

示例13: Generate

        public override string Generate(CreateTableExpression expression)
        {
            string FederatedOn = "";
             if (!(string.IsNullOrEmpty(expression.Federation.DistributionName) || string.IsNullOrEmpty(expression.FederationColumn)))
             {
            FederatedOn = string.Format(FederateTable, expression.Federation.DistributionName,
                                         expression.FederationColumn);
             }

             return Wrap(string.Format("{0} {1}", base.Generate(expression), FederatedOn));
        }
开发者ID:fire-eagle,项目名称:fluentmigrator,代码行数:11,代码来源:AzureGenerator.cs

示例14: Generate

        public override string Generate(CreateTableExpression expression)
        {
            var descriptionStatements = DescriptionGenerator.GenerateDescriptionStatements(expression);
            var createTableStatement = string.Format("CREATE TABLE {0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), base.Generate(expression));
            var descriptionStatementsArray = descriptionStatements as string[] ?? descriptionStatements.ToArray();

            if (!descriptionStatementsArray.Any())
                return createTableStatement;

            return ComposeStatements(createTableStatement, descriptionStatementsArray);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:11,代码来源:SqlServer2005Generator.cs

示例15: CanCreateTableExpression

        public void CanCreateTableExpression()
        {
            CreateTableExpression expression = new CreateTableExpression { TableName = tableName };
            expression.Columns.Add(column.Object);

            using (command)
            {
                processor.Process(expression);
                command.CommandText = string.Format("SELECT name FROM sqlite_master WHERE type='table' and name='{0}'", tableName);
                command.ExecuteReader().Read().ShouldBeTrue();
            }
        }
开发者ID:ryaneastabrook,项目名称:fluentmigrator,代码行数:12,代码来源:SqliteProcessorTests.cs


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