private void BaseAdd(DataTable table) { if (table == null) { throw ExceptionBuilder.ArgumentNull("table"); } if (table.DataSet == this.dataSet) { throw ExceptionBuilder.TableAlreadyInTheDataSet(); } if (table.DataSet != null) { throw ExceptionBuilder.TableAlreadyInOtherDataSet(); } if (table.TableName.Length == 0) { table.TableName = this.AssignName(); } else { if ((base.NamesEqual(table.TableName, this.dataSet.DataSetName, false, this.dataSet.Locale) != 0) && !table.fNestedInDataset) { throw ExceptionBuilder.DatasetConflictingName(this.dataSet.DataSetName); } this.RegisterName(table.TableName, table.Namespace); } table.SetDataSet(this.dataSet); }
/// <include file='doc\DataRelationCollection.uex' path='docs/doc[@for="DataRelationCollection.AddCore"]/*' /> /// <devdoc> /// Does verification on the table. /// An ArgumentNullException is thrown if this relation is null. An ArgumentException is thrown if this relation /// already belongs to this collection, belongs to another collection. /// A DuplicateNameException is thrown if this collection already has a relation with the same /// name (case insensitive). /// </devdoc> protected virtual void AddCore(DataRelation relation) { if (relation == null) { throw ExceptionBuilder.ArgumentNull("relation"); } relation.CheckState(); DataSet dataSet = GetDataSet(); if (relation.DataSet == dataSet) { throw ExceptionBuilder.RelationAlreadyInTheDataSet(); } if (relation.DataSet != null) { throw ExceptionBuilder.RelationAlreadyInOtherDataSet(); } if (relation.ChildTable.Locale.LCID != relation.ParentTable.Locale.LCID || relation.ChildTable.CaseSensitive != relation.ParentTable.CaseSensitive) { throw ExceptionBuilder.CaseLocaleMismatch(); } if (relation.Nested) { relation.ParentTable.ElementColumnCount++; } }
public DataTableReader(DataTable [] dataTables) { if (dataTables == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } if (dataTables.Length == 0) { throw ExceptionBuilder.DataTableReaderArgumentIsEmpty(); } tables = new DataTable[dataTables.Length]; for (int i = 0; i < dataTables.Length; i++) { if (dataTables[i] == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } tables[i] = dataTables[i]; } init(); // schemaTable = GetSchemaTableFromDataTable(currentDataTable); }
/// <summary> /// Does verification on the table and it's name, and points the table at the dataSet that owns this collection. /// An ArgumentNullException is thrown if this table is null. An ArgumentException is thrown if this table /// already belongs to this collection, belongs to another collection. /// A DuplicateNameException is thrown if this collection already has a table with the same /// name (case insensitive). /// </summary> private void BaseAdd(DataTable table) { if (table == null) { throw ExceptionBuilder.ArgumentNull(nameof(table)); } if (table.DataSet == _dataSet) { throw ExceptionBuilder.TableAlreadyInTheDataSet(); } if (table.DataSet != null) { throw ExceptionBuilder.TableAlreadyInOtherDataSet(); } if (table.TableName.Length == 0) { table.TableName = AssignName(); } else { if (NamesEqual(table.TableName, _dataSet.DataSetName, false, _dataSet.Locale) != 0 && !table._fNestedInDataset) { throw ExceptionBuilder.DatasetConflictingName(_dataSet.DataSetName); } RegisterName(table.TableName, table.Namespace); } table.SetDataSet(_dataSet); //must run thru the document incorporating the addition of this data table //must make sure there is no other schema component which have the same // identity as this table (for example, there must not be a table with the // same identity as a column in this schema. }
protected virtual void AddCore(DataRelation relation) { Bid.Trace("<ds.DataRelationCollection.AddCore|INFO> %d#, relation=%d\n", this.ObjectID, (relation != null) ? relation.ObjectID : 0); if (relation == null) { throw ExceptionBuilder.ArgumentNull("relation"); } relation.CheckState(); DataSet dataSet = this.GetDataSet(); if (relation.DataSet == dataSet) { throw ExceptionBuilder.RelationAlreadyInTheDataSet(); } if (relation.DataSet != null) { throw ExceptionBuilder.RelationAlreadyInOtherDataSet(); } if ((relation.ChildTable.Locale.LCID != relation.ParentTable.Locale.LCID) || (relation.ChildTable.CaseSensitive != relation.ParentTable.CaseSensitive)) { throw ExceptionBuilder.CaseLocaleMismatch(); } if (relation.Nested) { relation.CheckNamespaceValidityForNestedRelations(relation.ParentTable.Namespace); relation.ValidateMultipleNestedRelations(); DataTable parentTable = relation.ParentTable; parentTable.ElementColumnCount++; } }
public virtual DataViewSetting this[DataTable table] { get { if (table == null) { throw ExceptionBuilder.ArgumentNull("table"); } DataViewSetting setting = (DataViewSetting)this.list[table]; if (setting == null) { setting = new DataViewSetting(); this[table] = setting; } return(setting); } set { if (table == null) { throw ExceptionBuilder.ArgumentNull("table"); } value.SetDataViewManager(this.dataViewManager); value.SetDataTable(table); this.list[table] = value; } }
/// <summary> /// Does verification on the table. /// An ArgumentNullException is thrown if this relation is null. An ArgumentException is thrown if this relation /// already belongs to this collection, belongs to another collection. /// A DuplicateNameException is thrown if this collection already has a relation with the same /// name (case insensitive). /// </summary> protected virtual void AddCore(DataRelation relation) { DataCommonEventSource.Log.Trace("<ds.DataRelationCollection.AddCore|INFO> {0}, relation={1}", ObjectID, (relation != null) ? relation.ObjectID : 0); if (relation == null) { throw ExceptionBuilder.ArgumentNull(nameof(relation)); } relation.CheckState(); DataSet dataSet = GetDataSet(); if (relation.DataSet == dataSet) { throw ExceptionBuilder.RelationAlreadyInTheDataSet(); } if (relation.DataSet != null) { throw ExceptionBuilder.RelationAlreadyInOtherDataSet(); } if (relation.ChildTable.Locale.LCID != relation.ParentTable.Locale.LCID || relation.ChildTable.CaseSensitive != relation.ParentTable.CaseSensitive) { throw ExceptionBuilder.CaseLocaleMismatch(); } if (relation.Nested) { relation.CheckNamespaceValidityForNestedRelations(relation.ParentTable.Namespace); relation.ValidateMultipleNestedRelations(); relation.ParentTable.ElementColumnCount++; } }
public DataTableReader(DataTable[] dataTables) { this.isOpen = true; this.tableCounter = -1; this.rowCounter = -1; this.hasRows = true; if (dataTables == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } if (dataTables.Length == 0) { throw ExceptionBuilder.DataTableReaderArgumentIsEmpty(); } this.tables = new DataTable[dataTables.Length]; for (int i = 0; i < dataTables.Length; i++) { if (dataTables[i] == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } this.tables[i] = dataTables[i]; } this.init(); }
/// <summary> /// Gets the <see cref='System.Data.DataColumn'/> from the collection with the specified name. /// </summary> public DataColumn?this[string name] { get { if (null == name) { throw ExceptionBuilder.ArgumentNull(nameof(name)); } DataColumn?column; if ((!_columnFromName.TryGetValue(name, out column)) || (column == null)) { // Case-Insensitive compares int index = IndexOfCaseInsensitive(name); if (0 <= index) { column = (DataColumn)_list[index] !; } else if (-2 == index) { throw ExceptionBuilder.CaseInsensitiveNameConflict(name); } } return(column); } }
public virtual DataViewSetting this[DataTable table] { get { if (table == null) { throw ExceptionBuilder.ArgumentNull(nameof(table)); } DataViewSetting dataViewSetting = (DataViewSetting)_list[table]; if (dataViewSetting == null) { dataViewSetting = new DataViewSetting(); this[table] = dataViewSetting; } return(dataViewSetting); } set { if (table == null) { throw ExceptionBuilder.ArgumentNull(nameof(table)); } value.SetDataViewManager(_dataViewManager); value.SetDataTable(table); _list[table] = value; } }
internal RecordManager(DataTable table) { if (table == null) { throw ExceptionBuilder.ArgumentNull(nameof(table)); } _table = table; }
internal DataViewSettingCollection(DataViewManager dataViewManager) { if (dataViewManager == null) { throw ExceptionBuilder.ArgumentNull(nameof(dataViewManager)); } _dataViewManager = dataViewManager; }
internal RecordManager(DataTable table) { if (table == null) { throw ExceptionBuilder.ArgumentNull("table"); } this.table = table; }
internal DataViewSettingCollection(DataViewManager dataViewManager) { if (dataViewManager == null) { throw ExceptionBuilder.ArgumentNull("dataViewManager"); } this.dataViewManager = dataViewManager; }
/// <include file='doc\ConstraintCollection.uex' path='docs/doc[@for="ConstraintCollection.Add"]/*' /> /// <devdoc> /// <para> /// Adds the constraint to the collection.</para> /// </devdoc> public void Add(Constraint constraint) { if (constraint == null) { throw ExceptionBuilder.ArgumentNull("constraint"); } // It is an error if we find an equivalent constraint already in collection if (FindConstraint(constraint) != null) { throw ExceptionBuilder.DuplicateConstraint(FindConstraint(constraint).ConstraintName); } if (constraint is UniqueConstraint) { if (((UniqueConstraint)constraint).bPrimaryKey) { if (Table.primaryKey != null) { throw ExceptionBuilder.AddPrimaryKeyConstraint(); } } AddUniqueConstraint((UniqueConstraint)constraint); } else if (constraint is ForeignKeyConstraint) { ForeignKeyConstraint fk = (ForeignKeyConstraint)constraint; UniqueConstraint key = fk.RelatedTable.Constraints.FindKeyConstraint(fk.RelatedColumns); if (key == null) { if (constraint.ConstraintName.Length == 0) { constraint.ConstraintName = AssignName(); } else { RegisterName(constraint.ConstraintName); } key = new UniqueConstraint(fk.RelatedColumns); fk.RelatedTable.Constraints.Add(key); } AddForeignKeyConstraint((ForeignKeyConstraint)constraint); } BaseAdd(constraint); ArrayAdd(constraint); OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, constraint)); if (constraint is UniqueConstraint) { if (((UniqueConstraint)constraint).bPrimaryKey) { Table.PrimaryKey = ((UniqueConstraint)constraint).Columns; } } }
/// <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; } }
public RelatedView(DataColumn[] columns, object[] values) : base(columns[0].Table, false) { if (values == null) { throw ExceptionBuilder.ArgumentNull("values"); } this.key = new DataKey(columns, true); this.values = values; base.ResetRowViewCache(); }
internal void UpdataTable(DataTable datatable) { if (datatable == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } this.UnSubscribeEvents(); this.currentDataTable = datatable; this.SubscribeEvents(); }
private void CheckColumn(DataColumn column) { if (column == null) { throw ExceptionBuilder.ArgumentNull("column"); } if (column.Table != this._table) { throw ExceptionBuilder.ColumnNotInTheTable(column.ColumnName, this._table.TableName); } }
internal void UpdataTable(DataTable datatable) { if (datatable == null) { throw ExceptionBuilder.ArgumentNull(nameof(DataTable)); } UnSubscribeEvents(); _currentDataTable = datatable; SubscribeEvents(); }
/// <include file='doc\RelatedView.uex' path='docs/doc[@for="RelatedView.RelatedView"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public RelatedView(DataColumn[] columns, object[] values) : base(columns[0].Table) { if (values == null) { throw ExceptionBuilder.ArgumentNull("values"); } this.Columns = columns; this.Values = values; UpdateIndex(); Reset(); }
public bool Contains(string name, string tableNamespace) { if (name == null) { throw ExceptionBuilder.ArgumentNull("name"); } if (tableNamespace == null) { throw ExceptionBuilder.ArgumentNull("tableNamespace"); } return(this.InternalIndexOf(name, tableNamespace) >= 0); }
public DataTableReader(DataTable dataTable) { if (dataTable == null) { throw ExceptionBuilder.ArgumentNull(nameof(DataTable)); } _tables = new DataTable[1] { dataTable }; Init(); }
internal DataKey(DataColumn[] columns, bool copyColumns) { if (columns == null) { throw ExceptionBuilder.ArgumentNull(nameof(columns)); } if (columns.Length == 0) { throw ExceptionBuilder.KeyNoColumns(); } if (columns.Length > maxColumns) { throw ExceptionBuilder.KeyTooManyColumns(maxColumns); } for (int i = 0; i < columns.Length; i++) { if (columns[i] == null) { throw ExceptionBuilder.ArgumentNull("column"); } } for (int i = 0; i < columns.Length; i++) { for (int j = 0; j < i; j++) { if (columns[i] == columns[j]) { throw ExceptionBuilder.KeyDuplicateColumns(columns[i].ColumnName); } } } if (copyColumns) { // Need to make a copy of all columns _columns = new DataColumn[columns.Length]; for (int i = 0; i < columns.Length; i++) { _columns[i] = columns[i]; } } else { // take ownership of the array passed in _columns = columns; } CheckState(); }
public override int GetValues(object[] values) { ValidateState(nameof(GetValues)); ValidateReader(); if (values == null) { throw ExceptionBuilder.ArgumentNull(nameof(values)); } Array.Copy(_currentDataRow.ItemArray, values, _currentDataRow.ItemArray.Length > values.Length ? values.Length : _currentDataRow.ItemArray.Length); return(_currentDataRow.ItemArray.Length > values.Length ? values.Length : _currentDataRow.ItemArray.Length); }
public DataTableReader(DataTable dataTable) { this.isOpen = true; this.tableCounter = -1; this.rowCounter = -1; this.hasRows = true; if (dataTable == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } this.tables = new DataTable[] { dataTable }; this.init(); }
public DataTableReader(DataTable dataTable) { if (dataTable == null) { throw ExceptionBuilder.ArgumentNull("DataTable"); } tables = new DataTable[1] { dataTable }; init(); // schemaTable = GetSchemaTableFromDataTable(currentDataTable); }
override public Int32 GetValues(object[] values) { ValidateState("GetValues"); ValidateReader(); if (values == null) { throw ExceptionBuilder.ArgumentNull("values"); } Array.Copy(currentDataRow.ItemArray, values, currentDataRow.ItemArray.Length > values.Length ? values.Length : currentDataRow.ItemArray.Length); return(currentDataRow.ItemArray.Length > values.Length ? values.Length : currentDataRow.ItemArray.Length); }
public DataTable this[string name, string tableNamespace] { get { if (tableNamespace == null) { throw ExceptionBuilder.ArgumentNull("tableNamespace"); } int index = InternalIndexOf(name, tableNamespace); if (index == -2) { throw ExceptionBuilder.CaseInsensitiveNameConflict(name); } return((index < 0) ? null : (DataTable)_list[index]); } }
public RelatedView(DataColumn[] columns, object[] values) : base(columns[0].Table, false) { if (values == null) { throw ExceptionBuilder.ArgumentNull(nameof(values)); } _parentRowView = null; _parentKey = null; _childKey = new DataKey(columns, true); _filterValues = values; Debug.Assert(Table == _childKey.Table, "Key.Table Must be equal to Current Table"); base.ResetRowViewCache(); }