當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。