예제 #1
0
 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);
 }
예제 #2
0
        /// <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++;
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        /// <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++;
            }
        }
예제 #6
0
 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;
     }
 }
예제 #7
0
        /// <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();
 }
예제 #9
0
        /// <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);
            }
        }
예제 #10
0
 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;
     }
 }
예제 #11
0
 internal RecordManager(DataTable table)
 {
     if (table == null)
     {
         throw ExceptionBuilder.ArgumentNull(nameof(table));
     }
     _table = table;
 }
예제 #12
0
 internal DataViewSettingCollection(DataViewManager dataViewManager)
 {
     if (dataViewManager == null)
     {
         throw ExceptionBuilder.ArgumentNull(nameof(dataViewManager));
     }
     _dataViewManager = dataViewManager;
 }
예제 #13
0
 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;
                }
            }
        }
예제 #16
0
        /// <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;
            }
        }
예제 #17
0
 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();
 }
예제 #18
0
 internal void UpdataTable(DataTable datatable)
 {
     if (datatable == null)
     {
         throw ExceptionBuilder.ArgumentNull("DataTable");
     }
     this.UnSubscribeEvents();
     this.currentDataTable = datatable;
     this.SubscribeEvents();
 }
예제 #19
0
 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);
     }
 }
예제 #20
0
        internal void UpdataTable(DataTable datatable)
        {
            if (datatable == null)
            {
                throw ExceptionBuilder.ArgumentNull(nameof(DataTable));
            }

            UnSubscribeEvents();
            _currentDataTable = datatable;
            SubscribeEvents();
        }
예제 #21
0
 /// <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();
 }
예제 #22
0
 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);
 }
예제 #23
0
        public DataTableReader(DataTable dataTable)
        {
            if (dataTable == null)
            {
                throw ExceptionBuilder.ArgumentNull(nameof(DataTable));
            }
            _tables = new DataTable[1] {
                dataTable
            };

            Init();
        }
예제 #24
0
        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();
        }
예제 #25
0
        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();
 }
예제 #27
0
        public DataTableReader(DataTable dataTable)
        {
            if (dataTable == null)
            {
                throw ExceptionBuilder.ArgumentNull("DataTable");
            }
            tables = new DataTable[1] {
                dataTable
            };

            init();
//            schemaTable = GetSchemaTableFromDataTable(currentDataTable);
        }
예제 #28
0
        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]);
     }
 }
예제 #30
0
        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();
        }