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++;
            }
        }
Ejemplo n.º 2
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++;
            }
        }
Ejemplo n.º 3
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++;
            }
        }
Ejemplo n.º 4
0
 internal override void CheckCanAddToCollection(ConstraintCollection constraints)
 {
     if (Table != constraints.Table)
     {
         throw ExceptionBuilder.ConstraintAddFailed(constraints.Table);
     }
     if (Table.Locale.LCID != RelatedTable.Locale.LCID || Table.CaseSensitive != RelatedTable.CaseSensitive)
     {
         throw ExceptionBuilder.CaseLocaleMismatch();
     }
 }