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


C# Framework.Column类代码示例

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


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

示例1: ChangeColumn

		public override void ChangeColumn(string table, Column column)
		{
			if (!ColumnExists(table, column.Name))
			{
				Logger.Warn("Column {0}.{1} does not exist", table, column.Name);
				return;
			}

		    var existingColumn = GetColumnByName(table, column.Name);
		    
            column.Name = existingColumn.Name; // name might have different case.

			string tempColumn = "temp_" + column.Name;
			RenameColumn(table, column.Name, tempColumn);

			// check if this is not-null
			bool isNotNull = (column.ColumnProperty & ColumnProperty.NotNull) == ColumnProperty.NotNull;

			// remove the not-null option
			column.ColumnProperty = (column.ColumnProperty & ~ColumnProperty.NotNull);

			AddColumn(table, column);
			ExecuteQuery(String.Format("UPDATE {0} SET {1}={2}", table, Dialect.Quote(column.Name), tempColumn));
			RemoveColumn(table, tempColumn);

			// if is not null, set that now
            if (isNotNull) ExecuteQuery(string.Format("ALTER TABLE {0} ALTER COLUMN {1} SET NOT NULL", table, Dialect.Quote(column.Name)));
		}
开发者ID:modulexcite,项目名称:Migrator.NET,代码行数:28,代码来源:PostgreSQLTransformationProvider.cs

示例2: Up

        public override void Up()
        {
            var col = new Column("Url", DbType.String, 255, ColumnProperty.Null);

            foreach (string table in _tables)
                Database.AddColumn(table, col);
        }
开发者ID:robgray,项目名称:f1speedguides,代码行数:7,代码来源:009_AddUrlFieldToTables.cs

示例3: MapColumnProperties

		public override void MapColumnProperties(Column column)
		{
			Name = column.Name;

			indexed = PropertySelected(column.ColumnProperty, ColumnProperty.Indexed);

			var vals = new List<string>();

			AddName(vals);

			AddType(vals);

			AddIdentity(column, vals);

			AddUnsigned(column, vals);

			AddPrimaryKey(column, vals);

			AddIdentityAgain(column, vals);

			AddUnique(column, vals);

			AddForeignKey(column, vals);

			AddDefaultValue(column, vals);

			// null / not-null comes last on Oracle - otherwise if use Null/Not-null + default, bad things happen
			// (http://geekswithblogs.net/faizanahmad/archive/2009/08/07/add-new-columnfield-in-oracle-db-table---ora.aspx)

			AddNotNull(column, vals);

			AddNull(column, vals);

			columnSql = String.Join(" ", vals.ToArray());
		}
开发者ID:modulexcite,项目名称:Migrator.NET,代码行数:35,代码来源:OracleColumnPropertiesMapper.cs

示例4: IndexKeyColumn

        public IndexKeyColumn(Column column, SortDirection sortDirection)
        {
            if (column == null) throw new ArgumentNullException("column");

            Column = column;
            SortDirection = sortDirection;
        }
开发者ID:Inferis,项目名称:KindjesNet,代码行数:7,代码来源:IndexKeyColumn.cs

示例5: MapColumnProperties

        public void MapColumnProperties(Column column)
        {
            Name = column.Name;
            indexed = PropertySelected(column.ColumnProperty, ColumnProperty.Indexed);
            
            List<string> vals = new List<string>();
            vals.Add(dialect.ColumnNameNeedsQuote ? QuotedName : Name);
            
            vals.Add(type);
            
            if (! dialect.IdentityNeedsType)
                AddValueIfSelected(column, ColumnProperty.Identity, vals);
                
            AddValueIfSelected(column, ColumnProperty.Unsigned, vals);
            if (! PropertySelected(column.ColumnProperty, ColumnProperty.PrimaryKey) || dialect.NeedsNotNullForIdentity)
                AddValueIfSelected(column, ColumnProperty.NotNull, vals);
                
            AddValueIfSelected(column, ColumnProperty.PrimaryKey, vals);
            
            if (dialect.IdentityNeedsType)
                AddValueIfSelected(column, ColumnProperty.Identity, vals);
            
            AddValueIfSelected(column, ColumnProperty.Unique, vals);
            AddValueIfSelected(column, ColumnProperty.ForeignKey, vals);

            if (column.DefaultValue != null)
                vals.Add(dialect.Default(column.DefaultValue));

            columnSql = String.Join(" ", vals.ToArray());
        }
开发者ID:jango2015,项目名称:Migrator.NET,代码行数:30,代码来源:ColumnPropertiesMapper.cs

示例6: MapColumnProperties

		public virtual void MapColumnProperties(Column column)
		{
			Name = column.Name;

			indexed = PropertySelected(column.ColumnProperty, ColumnProperty.Indexed);

			var vals = new List<string>();

			AddName(vals);

			AddType(vals);

			AddIdentity(column, vals);

			AddUnsigned(column, vals);

			AddNotNull(column, vals);

			AddNull(column, vals);

			AddPrimaryKey(column, vals);

			AddIdentityAgain(column, vals);

			AddUnique(column, vals);

			AddForeignKey(column, vals);

			AddDefaultValue(column, vals);

			columnSql = String.Join(" ", vals.ToArray());
		}
开发者ID:modulexcite,项目名称:Migrator.NET,代码行数:32,代码来源:ColumnPropertiesMapper.cs

示例7: GetColumnMapper

 public ColumnPropertiesMapper GetColumnMapper(Column column)
 {
     string type = column.Size > 0 ? GetTypeName(column.Type, column.Size) : GetTypeName(column.Type);
     if (! IdentityNeedsType && column.IsIdentity)
         type = String.Empty;
     
     return new ColumnPropertiesMapper(this, type);
 }
开发者ID:wallymathieu,项目名称:Migrator.NET,代码行数:8,代码来源:Dialect.cs

示例8: GetAndMapColumnProperties

 public ColumnPropertiesMapper GetAndMapColumnProperties(Column column)
 {
     ColumnPropertiesMapper mapper = GetColumnMapper(column);
     mapper.MapColumnProperties(column);
     if (column.DefaultValue != null)
         mapper.Default = column.DefaultValue;
     return mapper;
 }
开发者ID:andrewseward,项目名称:migratordotnet,代码行数:8,代码来源:Dialect.cs

示例9: Int32_is_unsigned_compatible

        public void Int32_is_unsigned_compatible()
        {
            //arange
            Column column = new Column("test", DbType.Int32, ColumnProperty.Unsigned);

            //act
            ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(column);

            //assert
            StringAssert.Contains("UNSIGNED", mapper.ColumnSql);
        }
开发者ID:nats,项目名称:migratordotnet,代码行数:11,代码来源:MysqlDialectTest.cs

示例10: Guid_is_not_unsigned_compatible

        public void Guid_is_not_unsigned_compatible()
        {
            //arrange
            Column column = new Column("test", DbType.Guid, ColumnProperty.Unsigned);

            //act
            ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(column);

            //assert
            Assert.IsFalse(mapper.ColumnSql.Contains("UNSIGNED"));
        }
开发者ID:nats,项目名称:migratordotnet,代码行数:11,代码来源:MysqlDialectTest.cs

示例11: MergeNameWithStandardFields

 public static Column[] MergeNameWithStandardFields(string indicatedName, Column nameColumn)
 {
     return new[]
     {
         new Column(CreatePrimaryKeyColumnName(indicatedName), DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
         nameColumn,
         new Column("Depricated", DbType.Boolean, ColumnProperty.NotNull, 0),
         new Column("IsDeleted", DbType.Boolean, ColumnProperty.Null, 0),
         new Column("CreatedBy", DbType.Int32, ColumnProperty.NotNull),
         new Column("CreatedDate", DbType.DateTime, ColumnProperty.NotNull, "(getdate())")
     };
 }
开发者ID:Aranjedeath,项目名称:SpecimenCode,代码行数:12,代码来源:LookupTableHelper.cs

示例12: ChangeColumn

		public override void ChangeColumn(string table, Column column)
		{
			if (!ColumnExists(table, column.Name))
			{
				Logger.Warn("Column {0}.{1} does not exist", table, column.Name);
				return;
			}

			var existingColumn = GetColumnByName(table, column.Name);
			
			if (column.Type == DbType.String)
			{
				RenameColumn(table, column.Name, TemporaryColumnName);

				// check if this is not-null
				bool isNotNull = (column.ColumnProperty & ColumnProperty.NotNull) == ColumnProperty.NotNull;

				// remove the not-null option
				column.ColumnProperty = (column.ColumnProperty & ~ColumnProperty.NotNull);

				AddColumn(table, column);
				CopyDataFromOneColumnToAnother(table, TemporaryColumnName, column.Name);
				RemoveColumn(table, TemporaryColumnName);
				//RenameColumn(table, TemporaryColumnName, column.Name);
				
				string columnName = QuoteColumnNameIfRequired(column.Name);
				
				// now set the column to not-null
				if (isNotNull) ExecuteQuery(String.Format("ALTER TABLE {0} MODIFY ({1} NOT NULL)", table, columnName));
			}
			else
			{
				if (((existingColumn.ColumnProperty & ColumnProperty.NotNull) == ColumnProperty.NotNull)
					&& ((column.ColumnProperty & ColumnProperty.NotNull) == ColumnProperty.NotNull))
				{
					// was not null, 	and is being change to not-null - drop the not-null all together
					column.ColumnProperty = column.ColumnProperty & ~ColumnProperty.NotNull;
				}
				else if 
					(((existingColumn.ColumnProperty & ColumnProperty.Null) == ColumnProperty.Null)
					&& ((column.ColumnProperty & ColumnProperty.Null) == ColumnProperty.Null))
				{
					// was null, and is being changed to null - drop the null all together
					column.ColumnProperty = column.ColumnProperty & ~ColumnProperty.Null;
				}
			
				ColumnPropertiesMapper mapper = _dialect.GetAndMapColumnProperties(column);

				ChangeColumn(table, mapper.ColumnSql);
			}
		}
开发者ID:rvaccari,项目名称:Migrator.NET,代码行数:51,代码来源:OracleTransformationProvider.cs

示例13: ChangeColumn

		public override void ChangeColumn(string table, Column column)
		{
			if (!ColumnExists(table, column.Name))
			{
				Logger.Warn("Column {0}.{1} does not exist", table, column.Name);
				return;
			}

			string tempColumn = "temp_" + column.Name;
			RenameColumn(table, column.Name, tempColumn);
			AddColumn(table, column);
			ExecuteQuery(String.Format("UPDATE {0} SET {1}={2}", table, column.Name, tempColumn));
			RemoveColumn(table, tempColumn);
		}
开发者ID:Velir,项目名称:Migrator.NET,代码行数:14,代码来源:SQLiteTransformationProvider.cs

示例14: Up

        public override void Up()
        {
            Column[] columns = new Column[]
                                   {
                                       new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
                                       new Column("TaskId", DbType.Int32,
                                                  ColumnProperty.ForeignKey | ColumnProperty.NotNull),
                                       new Column("Estimate", DbType.Double, ColumnProperty.NotNull),
                                       new Column("Timestamp", DbType.DateTime, ColumnProperty.NotNull)
                                   };

            Database.AddTable("TaskEstimateHistory", columns);
            Database.AddForeignKey("FK_TaskEstimateHistory_Task", "TaskEstimateHistory", "TaskId", "Tasks", "Id", ForeignKeyConstraint.Cascade);
        }
开发者ID:browsk,项目名称:juice,代码行数:14,代码来源:006_AddTaskEstimateHistoryTabls.cs

示例15: Up

 public override void Up()
 {
     Column[] columns = new Column[]
                            {
                                new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
                                new Column("Name", DbType.String, 255, ColumnProperty.NotNull),
                                new Column("Description", DbType.String),
                                new Column("BusinessValue", DbType.Int32),
                                new Column("Priority", DbType.Int32),
                                new Column("Estimate", DbType.Int32),
                                new Column("ProjectId", DbType.Int32, ColumnProperty.ForeignKey | ColumnProperty.NotNull),
                            };
     Database.AddTable("Stories", columns);
     Database.AddForeignKey("FK_Stories_Project", "Stories", "ProjectId", "Projects", "Id", ForeignKeyConstraint.Cascade);
 }
开发者ID:browsk,项目名称:juice,代码行数:15,代码来源:004_AddStoriesTable.cs


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