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

C# Framework.Column类代码示例

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

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



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


示例16: 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(!string.IsNullOrEmpty(column.Collation))
            {
                if(new DbType[] { DbType.String, DbType.StringFixedLength, DbType.AnsiString, DbType.AnsiStringFixedLength }.Contains(column.Type))
                {
                    vals.Add(dialect.AddCollation(column.Collation));
                }
            }

            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);
            }
            else
            {
                AddValueIfSelected(column, ColumnProperty.Null, 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:mmsommer,项目名称:OGD.Database.Migrator.Net,代码行数:44,代码来源:ColumnPropertiesMapper.cs


示例17: GetColumns

		public virtual Column[] GetColumns(string table)
		{
			var columns = new List<Column>();
			using (
				IDataReader reader =
					ExecuteQuery(
						String.Format("select COLUMN_NAME, IS_NULLABLE from INFORMATION_SCHEMA.COLUMNS where table_name = '{0}'", table)))
			{
				while (reader.Read())
				{
					var column = new Column(reader.GetString(0), DbType.String);
					string nullableStr = reader.GetString(1);
					bool isNullable = nullableStr == "YES";
					column.ColumnProperty |= isNullable ? ColumnProperty.Null : ColumnProperty.NotNull;

					columns.Add(column);
				}
			}

			return columns.ToArray();
		}
开发者ID:eliog,项目名称:Migrator.NET,代码行数:21,代码来源:TransformationProvider.cs


示例18: 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 tempColumn = new Column("temp_" + column.Name)
                             {
                                 ColumnProperty = column.ColumnProperty,
                                 DefaultValue = column.DefaultValue ?? null,
                                 Size = column.Size,
                                 Type = column.Type
                             };

            AddColumn(table, tempColumn);
            ExecuteQuery(String.Format("UPDATE {0} SET {1}={2}", table, tempColumn.Name, column.Name));
            RemoveColumn(table, column.Name);
            RenameColumn(table, tempColumn.Name, column.Name);
        }
开发者ID:Odyl,项目名称:MigratorDotNet,代码行数:21,代码来源:PostgreSQLTransformationProvider.cs


示例19: GetColumns

        // XXX: Using INFORMATION_SCHEMA.COLUMNS should work, but it was causing trouble, so I used the MySQL specific thing.
        public override Column[] GetColumns(string table)
        {
            List<Column> columns = new List<Column>();
            using (
                IDataReader reader =
                    ExecuteQuery(
                        String.Format("SHOW COLUMNS FROM {0}", table)))
            {
                while (reader.Read())
                {
                    Column column = new Column(reader.GetString(0), DbType.String);
                    string nullableStr = reader.GetString(2);
                    bool isNullable = nullableStr == "YES";
                    column.ColumnProperty |= isNullable ? ColumnProperty.Null : ColumnProperty.NotNull;

                    columns.Add(column);
                }
            }

            return columns.ToArray();
        }
开发者ID:jango2015,项目名称:Migrator.NET,代码行数:22,代码来源:MySqlTransformationProvider.cs


示例20: AddColumn

			}
		}

		public void AddColumn(string table, Column column)
开发者ID:asynchrony,项目名称:Migrator.NET,代码行数:4,代码来源:TransformationProvider.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Framework.ForeignKeyConstraint类代码示例发布时间:2022-05-26
下一篇:
C# DocumentObjectModel.DocumentObject类代码示例发布时间: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