當前位置: 首頁>>代碼示例>>C#>>正文


C# DataColumn.AutoIncrementValue方法代碼示例

本文整理匯總了C#中System.Data.DataColumn.AutoIncrementValue方法的典型用法代碼示例。如果您正苦於以下問題:C# DataColumn.AutoIncrementValue方法的具體用法?C# DataColumn.AutoIncrementValue怎麽用?C# DataColumn.AutoIncrementValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.AutoIncrementValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Add

		/// <summary>
		/// Creates and adds the specified DataColumn object to the DataColumnCollection.
		/// </summary>
		/// <param name="column">The DataColumn to add.</param>
		public void Add(DataColumn column)
		{

			if (column == null)
				throw new ArgumentNullException ("column", "'column' argument cannot be null.");

			if (column.ColumnName.Equals(String.Empty))
			{
				column.ColumnName = GetNextDefaultColumnName ();
			}

//			if (Contains(column.ColumnName))
//				throw new DuplicateNameException("A DataColumn named '" + column.ColumnName + "' already belongs to this DataTable.");

			if (column.Table != null)
				throw new ArgumentException ("Column '" + column.ColumnName + "' already belongs to this or another DataTable.");

			CollectionChangeEventArgs e = new CollectionChangeEventArgs(CollectionChangeAction.Add, this);

			column.SetTable (parentTable);
			RegisterName(column.ColumnName, column);
			int ordinal = base.List.Add(column);
			column.SetOrdinal (ordinal);

			// if table already has rows we need to allocate space 
			// in the column data container 
			if ( parentTable.Rows.Count > 0 ) {
				column.DataContainer.Capacity = parentTable.RecordCache.CurrentCapacity;
			}

			if (column.AutoIncrement) {
				DataRowCollection rows = column.Table.Rows;
				for (int i = 0; i < rows.Count; i++)
					rows [i] [ordinal] = column.AutoIncrementValue ();
			}

			if (column.AutoIncrement)
				autoIncrement.Add(column);

			OnCollectionChanged (e);
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:45,代碼來源:DataColumnCollection.cs

示例2: Add

		/// <summary>
		/// Creates and adds the specified DataColumn object to the DataColumnCollection.
		/// </summary>
		/// <param name="column">The DataColumn to add.</param>
		public void Add (DataColumn column)
		{
			if (column == null)
				throw new ArgumentNullException ("column", "'column' argument cannot be null.");


			if (column.ColumnName.Length == 0) {
				column.ColumnName = GetNextDefaultColumnName ();
			}

//			if (Contains(column.ColumnName))
//				throw new DuplicateNameException("A DataColumn named '" + column.ColumnName + "' already belongs to this DataTable.");

			if (column.Table != null)
				throw new ArgumentException ("Column '" + column.ColumnName + "' already belongs to this or another DataTable.");

			column.SetTable (parentTable);
			RegisterName (column.ColumnName, column);
			int ordinal = base.List.Add (column);

			column.Ordinal = ordinal;

			// Check if the Column Expression is ok
			if (column.CompiledExpression != null)
				if (parentTable.Rows.Count == 0)
					column.CompiledExpression.Eval (parentTable.NewRow());
				else
					column.CompiledExpression.Eval (parentTable.Rows[0]);

			// if table already has rows we need to allocate space
			// in the column data container
			if (parentTable.Rows.Count > 0)
				column.DataContainer.Capacity = parentTable.RecordCache.CurrentCapacity;

			if (column.AutoIncrement) {
				DataRowCollection rows = column.Table.Rows;
				for (int i = 0; i < rows.Count; i++)
					rows [i] [ordinal] = column.AutoIncrementValue ();
			}

			if (column.AutoIncrement)
				autoIncrement.Add (column);

			column.PropertyChanged += new PropertyChangedEventHandler (ColumnPropertyChanged);

			OnCollectionChanged (new CollectionChangeEventArgs(CollectionChangeAction.Add, column));
		}
開發者ID:jamescourtney,項目名稱:mono,代碼行數:51,代碼來源:DataColumnCollection.cs


注:本文中的System.Data.DataColumn.AutoIncrementValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。