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


C# DataColumn.SetCapacity方法代码示例

本文整理汇总了C#中System.Data.DataColumn.SetCapacity方法的典型用法代码示例。如果您正苦于以下问题:C# DataColumn.SetCapacity方法的具体用法?C# DataColumn.SetCapacity怎么用?C# DataColumn.SetCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataColumn的用法示例。


在下文中一共展示了DataColumn.SetCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BaseAdd

 private void BaseAdd(DataColumn column)
 {
     if (column == null)
     {
         throw ExceptionBuilder.ArgumentNull("column");
     }
     if (column.table == this.table)
     {
         throw ExceptionBuilder.CannotAddColumn1(column.ColumnName);
     }
     if (column.table != null)
     {
         throw ExceptionBuilder.CannotAddColumn2(column.ColumnName);
     }
     if (column.ColumnName.Length == 0)
     {
         column.ColumnName = this.AssignName();
     }
     this.RegisterColumnName(column.ColumnName, column, null);
     try
     {
         column.SetTable(this.table);
         if ((!this.table.fInitInProgress && column.Computed) && column.DataExpression.DependsOn(column))
         {
             throw ExceptionBuilder.ExpressionCircular();
         }
         if (0 < this.table.RecordCapacity)
         {
             column.SetCapacity(this.table.RecordCapacity);
         }
         for (int i = 0; i < this.table.RecordCapacity; i++)
         {
             column.InitializeRecord(i);
         }
         if (this.table.DataSet != null)
         {
             column.OnSetDataSet();
         }
     }
     catch (Exception exception)
     {
         if (ADP.IsCatchableOrSecurityExceptionType(exception))
         {
             this.UnregisterName(column.ColumnName);
         }
         throw;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:48,代码来源:DataColumnCollection.cs

示例2: BaseAdd

        /// <devdoc>
        /// Does verification on the column and it's name, and points the column at the dataSet that owns this collection.
        /// An ArgumentNullException is thrown if this column is null.  An ArgumentException is thrown if this column
        /// already belongs to this collection, belongs to another collection.
        /// A DuplicateNameException is thrown if this collection already has a column with the same
        /// name (case insensitive).
        /// </devdoc>
        private void BaseAdd(DataColumn column) {
            if (column == null)
                throw ExceptionBuilder.ArgumentNull("column");
            if (column.table == table)
                throw ExceptionBuilder.CannotAddColumn1(column.ColumnName);
            if (column.table != null)
                throw ExceptionBuilder.CannotAddColumn2(column.ColumnName);
            
            if (column.ColumnName.Length == 0) {
                column.ColumnName = AssignName();
            }
            RegisterColumnName(column.ColumnName, column);
            try {
                column.SetTable(table);
                if (!table.fInitInProgress && column.Computed) {
                    if (column.DataExpression.DependsOn(column)) {
                        throw ExceptionBuilder.ExpressionCircular();
                    }
                }

                if (0 < table.RecordCapacity) {
                    // adding a column to table with existing rows
                    column.SetCapacity(table.RecordCapacity);
                }

                // fill column with default value.
                for (int record = 0; record < table.RecordCapacity; record++) {
                    column.InitializeRecord(record);
                }

                if (table.DataSet != null) {
                    column.OnSetDataSet();
                }
            }
            catch (Exception e) {
                // 
                if (ADP.IsCatchableOrSecurityExceptionType(e)) {
                    UnregisterName(column.ColumnName);
                }
                throw;
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:49,代码来源:DataColumnCollection.cs


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