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


C# Model.ColumnDefinition类代码示例

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


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


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