• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Model.ColumnDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FormatNullable

        protected override string FormatNullable(ColumnDefinition column)
        {
            if (column.IsNullable.GetValueOrDefault())
                return column.ModificationType == ColumnModificationType.Alter ? "NULL" : string.Empty;

            return "NOT NULL";
        }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:7,代码来源:SqlServerCeColumn.cs


示例2: ColumnTypesMatch

 public static bool ColumnTypesMatch(ColumnDefinition col1, ColumnDefinition col2)
 {
     FirebirdColumn column = new FirebirdColumn(new FirebirdOptions());
     string colDef1 = column.GenerateForTypeAlter(col1);
     string colDef2 = column.GenerateForTypeAlter(col2);
     return colDef1 == colDef2;
 }
开发者ID:akema-fr,项目名称:fluentmigrator,代码行数:7,代码来源:FirebirdGenerator.cs


示例3: WriteColumn

        protected void WriteColumn(ColumnDefinition column, StreamWriter output, bool isLastColumn)
        {
            string columnSyntax = ".WithColumn(\"" + column.Name + "\")";
            switch (column.Type)
            {
                case DbType.Boolean:
                    columnSyntax += ".AsBoolean()";
                    break;
                case DbType.Int16:
                    columnSyntax += ".AsInt16()";
                    break;
                case DbType.Int32:
                    columnSyntax += ".AsInt32()";
                    break;
                default:
                    columnSyntax += ".AsString()";
                    break;
            }
            if (column.IsIdentity)
                columnSyntax += ".Identity()";
            else if (column.IsIndexed)
                columnSyntax += ".Indexed()";

            if (column.IsNullable == false)
                columnSyntax += ".NotNullable()";

            if (isLastColumn) columnSyntax += ";";
            output.WriteLine("\t\t\t\t" + columnSyntax);
        }
开发者ID:modulexcite,项目名称:FluentMigratorSchemaDumper,代码行数:29,代码来源:RCDumpWriter.cs


示例4: GenerateAlterClause

        public string GenerateAlterClause(ColumnDefinition column)
        {
            if (column.IsIdentity)
            {
                throw new NotSupportedException("Altering an identity column is not supported.");
            }

            var alterClauses = AlterClauseOrder.Aggregate(new StringBuilder(), (acc, newRow) =>
            {
                var clause = newRow(column);
                if (acc.Length == 0)
                {
                    acc.Append(newRow(column));
                }
                else if (!string.IsNullOrEmpty(clause))
                {
                    acc.Append(clause.PadLeft(clause.Length + 1));
                }

                return acc;
            });

            return string.Format(
                "ALTER COLUMN {0} SET DATA TYPE {1}",
                Quoter.QuoteColumnName(column.Name),
                alterClauses);
        }
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:27,代码来源:Db2Column.cs


示例5: GenerateDDLForColumn

        public virtual string GenerateDDLForColumn(ColumnDefinition column)
        {
            var sb = new StringBuilder();

            sb.Append(column.Name);
            sb.Append(" ");
            sb.Append(GetTypeMap(column.Type.Value, column.Size, column.Precision));

            if (!column.IsNullable)
            {
                sb.Append(" NOT NULL");
            }

            if (column.DefaultValue != null)
            {
                sb.Append(" DEFAULT ");
                sb.Append(GetConstantValue(column.DefaultValue));
            }

            if (column.IsIdentity)
            {
                sb.Append(" IDENTITY(1,1)");
            }

            if (column.IsPrimaryKey)
            {
                sb.Append(" PRIMARY KEY CLUSTERED");
            }

            return sb.ToString();
        }
开发者ID:rtw,项目名称:fluentmigrator,代码行数:31,代码来源:GeneratorBase.cs


示例6: FormatType

        protected override string FormatType(ColumnDefinition column)
        {
            if (column.IsIdentity)
                return GetTypeMap(DbType.Int32, column.Size, column.Precision);

            return base.FormatType(column);
        }
开发者ID:gliljas,项目名称:fluentmigrator,代码行数:7,代码来源:SqliteColumn.cs


示例7: FormatType

        protected virtual string FormatType(ColumnDefinition column)
        {
            if (!column.Type.HasValue)
                return column.CustomType;

            return GetTypeMap(column.Type.Value, column.Size, column.Precision);
        }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:7,代码来源:ColumnBase.cs


示例8: Truncate

 public void Truncate(ColumnDefinition column)
 {
     column.Name = Truncate(column.Name);
     column.TableName = Truncate(column.TableName);
     if (column.IsPrimaryKey)
         column.PrimaryKeyName = packKeyNames ? Pack(column.PrimaryKeyName) : Truncate(column.PrimaryKeyName);
 }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:7,代码来源:FirebirdTruncator.cs


示例9: FormatIdentity

 protected override string FormatIdentity(ColumnDefinition column)
 {
     if (column.IsIdentity)
     {
         //todo: would like to throw a warning here
     }
     return string.Empty;
 }
开发者ID:minhajuddin,项目名称:fluentmigrator,代码行数:8,代码来源:OracleColumn.cs


示例10: CanAddColumnWithGetDateDefault

 public void CanAddColumnWithGetDateDefault()
 {
     ColumnDefinition column = new ColumnDefinition { Name = "TestColumn1", Type = DbType.String,
         Size = 5, DefaultValue = "GetDate()" };
     var expression = new CreateColumnExpression { TableName = "TestTable1", Column = column };
     var sql = _generator.Generate(expression);
     sql.ShouldBe("ALTER TABLE [TestTable1] ADD [TestColumn1] NVARCHAR(5) NOT NULL DEFAULT GetDate()");
 }
开发者ID:remids,项目名称:fluentmigrator,代码行数:8,代码来源:SqlServer2000AlterTableTests.cs


示例11: FormatPrimaryKey

        protected override string FormatPrimaryKey(ColumnDefinition column)
        {
            if (!column.IsPrimaryKey)
                return string.Empty;

            //Assume that if its IDENTITY and PRIMARY KEY, the it should be an AUTOINCREMENT column
            return !column.IsIdentity ? "PRIMARY KEY" : "PRIMARY KEY AUTOINCREMENT";
        }
开发者ID:gliljas,项目名称:fluentmigrator,代码行数:8,代码来源:SqliteColumn.cs


示例12: CanUseSystemMethodCurrentDateTimeAsADefaultValueForAColumn

        public void CanUseSystemMethodCurrentDateTimeAsADefaultValueForAColumn()
        {
            var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 15, Type = null, CustomType = "TIMESTAMP", DefaultValue = SystemMethods.CurrentDateTime };
            var expression = new CreateColumnExpression { Column = columnDefinition, TableName = "NewTable" };

            var result = Generator.Generate(expression);
            result.ShouldBe("ALTER TABLE `NewTable` ADD COLUMN `NewColumn` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:8,代码来源:MySqlGeneratorTests.cs


示例13: FormatIdentity

 protected override string FormatIdentity(ColumnDefinition column)
 {
     if (column.IsIdentity)
     {
         throw new DatabaseOperationNotSupportedException("Oracle does not support identity columns. Please use a SEQUENCE instead");
     }
     return string.Empty;
 }
开发者ID:kevin3274,项目名称:fluentmigrator,代码行数:8,代码来源:OracleColumn.cs


示例14: FormatDefaultValue

        protected override string FormatDefaultValue(ColumnDefinition column)
        {
            var defaultValue = base.FormatDefaultValue(column);

            if(!string.IsNullOrEmpty(defaultValue))
                return string.Format("CONSTRAINT DF_{0}_{1} ", column.TableName, column.Name) + defaultValue;

            return string.Empty;
        }
开发者ID:heinrichbreedt,项目名称:fluentmigrator,代码行数:9,代码来源:SqlServerColumn.cs


示例15: FormatNullable

        protected virtual string FormatNullable(ColumnDefinition column)
        {
			if (column.IsNullable.HasValue && column.IsNullable.Value) {
				return string.Empty;
			}
			else {
				return "NOT NULL";
			}
        }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:9,代码来源:ColumnBase.cs


示例16: FormatNullable

        protected override string FormatNullable(ColumnDefinition column)
        {
            if (!(column.DefaultValue is ColumnDefinition.UndefinedDefaultValue))
                return string.Empty;

            return column.IsNullable.HasValue 
                ? (column.IsNullable.Value ? "NULL" : "NOT NULL") 
                : String.Empty;
        }        
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:9,代码来源:HanaColumn.cs


示例17: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn

        public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
        {
            const string tableName = "NewTable";
            var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentUTCDateTime };
            var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };

            var result = Generator.Generate(expression);
            result.ShouldBe("ALTER TABLE \"public\".\"NewTable\" ADD \"NewColumn\" varchar(5) NOT NULL DEFAULT (now() at time zone 'UTC')");
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:9,代码来源:PostgresGeneratorTests.cs


示例18: CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn

        public void CanUseSystemMethodCurrentUTCDateTimeAsADefaultValueForAColumn()
        {
            const string tableName = "NewTable";
            var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 5, Type = DbType.String, DefaultValue = SystemMethods.CurrentUTCDateTime };
            var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };

            var result = Generator.Generate(expression);
            result.ShouldBe("ALTER TABLE NewTable ADD COLUMN NewColumn VARGRAPHIC(5) CCSID 1200 NOT NULL DEFAULT (CURRENT_TIMESTAMP - CURRENT_TIMEZONE)");
        }
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:9,代码来源:Db2GeneratorTests.cs


示例19: CanUseSystemMethodCurrentUserAsADefaultValueForAColumn

        public void CanUseSystemMethodCurrentUserAsADefaultValueForAColumn()
        {
            const string tableName = "NewTable";
            var columnDefinition = new ColumnDefinition { Name = "NewColumn", Size = 18, Type = DbType.AnsiString, DefaultValue = SystemMethods.CurrentUser };
            var expression = new CreateColumnExpression { Column = columnDefinition, TableName = tableName };

            var result = Generator.Generate(expression);
            result.ShouldBe("ALTER TABLE NewTable ADD COLUMN NewColumn VARCHAR(18) NOT NULL DEFAULT USER");
        }
开发者ID:BhuvanB,项目名称:fluentmigrator,代码行数:9,代码来源:Db2GeneratorTests.cs


示例20: FormatAlterNullable

        private string FormatAlterNullable(ColumnDefinition column)
        {
            if (!column.IsNullable.HasValue)
                return "";

            if (column.IsNullable.Value)
                return "DROP NOT NULL";

            return "SET NOT NULL";
        }
开发者ID:SaltyDH,项目名称:fluentmigrator,代码行数:10,代码来源:PostgresColumn.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Runner.MigrationRunner类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.UpdateDataExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap