Inheritance: ForeignKeyConstraintEnumerator
        internal bool CanRemove(DataTable table, bool fThrowException) {
            IntPtr hscp;
            Bid.ScopeEnter(out hscp, "<ds.DataTableCollection.CanRemove|INFO> %d#, table=%d, fThrowException=%d{bool}\n", ObjectID, (table != null)? table.ObjectID : 0 , fThrowException);
            try {
                if (table == null) {
                    if (!fThrowException)
                        return false;
                    else
                        throw ExceptionBuilder.ArgumentNull("table");
                }
                if (table.DataSet != dataSet) {
                    if (!fThrowException)
                        return false;
                    else
                        throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                }

                // allow subclasses to throw.
                dataSet.OnRemoveTable(table);

                if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0) {
                    if (!fThrowException)
                        return false;
                    else
                        throw ExceptionBuilder.TableInRelation();
                }

                for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();) {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // we can go with (constraint.Table ==  constraint.RelatedTable)
                        continue;
                    if (!fThrowException)
                        return false;
                    else
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                }

                for (ChildForeignKeyConstraintEnumerator constraints = new ChildForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();) {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // bug 97670
                        continue;

                    if (!fThrowException)
                        return false;
                    else
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                }

                return true;
            }
            finally{
                Bid.ScopeLeave(ref hscp);
            }
        }
Esempio n. 2
0
        internal bool CanRemove(DataTable table, bool fThrowException)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTableCollection.CanRemove|INFO> {0}, table={1}, fThrowException={2}", ObjectID, (table != null) ? table.ObjectID : 0, fThrowException);

            try
            {
                if (table == null)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    throw ExceptionBuilder.ArgumentNull(nameof(table));
                }
                if (table.DataSet != _dataSet)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                }

                // allow subclasses to throw.
                _dataSet.OnRemoveTable(table);

                if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    throw ExceptionBuilder.TableInRelation();
                }

                for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(_dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // we can go with (constraint.Table ==  constraint.RelatedTable)
                    {
                        continue;
                    }
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                for (ChildForeignKeyConstraintEnumerator constraints = new ChildForeignKeyConstraintEnumerator(_dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table)
                    {
                        continue;
                    }

                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                return(true);
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }
Esempio n. 3
0
        internal bool CanRemove(DataTable table, bool fThrowException)
        {
            if (table == null)
            {
                if (!fThrowException)
                {
                    return(false);
                }
                else
                {
                    throw ExceptionBuilder.ArgumentNull("table");
                }
            }
            if (table.DataSet != dataSet)
            {
                if (!fThrowException)
                {
                    return(false);
                }
                else
                {
                    throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                }
            }

            // allow subclasses to throw.
            dataSet.OnRemoveTableHack(table);

            if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0)
            {
                if (!fThrowException)
                {
                    return(false);
                }
                else
                {
                    throw ExceptionBuilder.TableInRelation();
                }
            }

            for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();)
            {
                ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                if (!fThrowException)
                {
                    return(false);
                }
                else
                {
                    throw ExceptionBuilder.TableInConstraint(table, constraint);
                }
            }

            for (ChildForeignKeyConstraintEnumerator constraints = new ChildForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();)
            {
                ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                if (!fThrowException)
                {
                    return(false);
                }
                else
                {
                    throw ExceptionBuilder.TableInConstraint(table, constraint);
                }
            }

            return(true);
        }
        internal bool CanRemove(DataTable table, bool fThrowException)
        {
            IntPtr hscp;

            Bid.ScopeEnter(out hscp, "<ds.DataTableCollection.CanRemove|INFO> %d#, table=%d, fThrowException=%d{bool}\n", ObjectID, (table != null)? table.ObjectID : 0, fThrowException);
            try {
                if (table == null)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.ArgumentNull("table");
                    }
                }
                if (table.DataSet != dataSet)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                    }
                }

                // allow subclasses to throw.
                dataSet.OnRemoveTable(table);

                if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0)
                {
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInRelation();
                    }
                }

                for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // we can go with (constraint.Table ==  constraint.RelatedTable)
                    {
                        continue;
                    }
                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                for (ChildForeignKeyConstraintEnumerator constraints = new ChildForeignKeyConstraintEnumerator(dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // bug 97670
                    {
                        continue;
                    }

                    if (!fThrowException)
                    {
                        return(false);
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                return(true);
            }
            finally{
                Bid.ScopeLeave(ref hscp);
            }
        }
Esempio n. 5
0
        internal bool CanRemove(DataTable table, bool fThrowException)
        {
            bool   flag;
            IntPtr ptr;

            Bid.ScopeEnter(out ptr, "<ds.DataTableCollection.CanRemove|INFO> %d#, table=%d, fThrowException=%d{bool}\n", this.ObjectID, (table != null) ? table.ObjectID : 0, fThrowException);
            try
            {
                if (table == null)
                {
                    if (fThrowException)
                    {
                        throw ExceptionBuilder.ArgumentNull("table");
                    }
                    return(false);
                }
                if (table.DataSet != this.dataSet)
                {
                    if (fThrowException)
                    {
                        throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                    }
                    return(false);
                }
                this.dataSet.OnRemoveTable(table);
                if ((table.ChildRelations.Count != 0) || (table.ParentRelations.Count != 0))
                {
                    if (fThrowException)
                    {
                        throw ExceptionBuilder.TableInRelation();
                    }
                    return(false);
                }
                ParentForeignKeyConstraintEnumerator enumerator2 = new ParentForeignKeyConstraintEnumerator(this.dataSet, table);
                while (enumerator2.GetNext())
                {
                    ForeignKeyConstraint foreignKeyConstraint = enumerator2.GetForeignKeyConstraint();
                    if ((foreignKeyConstraint.Table != table) || (foreignKeyConstraint.RelatedTable != table))
                    {
                        if (fThrowException)
                        {
                            throw ExceptionBuilder.TableInConstraint(table, foreignKeyConstraint);
                        }
                        return(false);
                    }
                }
                ChildForeignKeyConstraintEnumerator enumerator = new ChildForeignKeyConstraintEnumerator(this.dataSet, table);
                while (enumerator.GetNext())
                {
                    ForeignKeyConstraint constraint = enumerator.GetForeignKeyConstraint();
                    if ((constraint.Table != table) || (constraint.RelatedTable != table))
                    {
                        if (fThrowException)
                        {
                            throw ExceptionBuilder.TableInConstraint(table, constraint);
                        }
                        return(false);
                    }
                }
                flag = true;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(flag);
        }
 internal bool CanRemove(DataTable table, bool fThrowException)
 {
     bool flag;
     IntPtr ptr;
     Bid.ScopeEnter(out ptr, "<ds.DataTableCollection.CanRemove|INFO> %d#, table=%d, fThrowException=%d{bool}\n", this.ObjectID, (table != null) ? table.ObjectID : 0, fThrowException);
     try
     {
         if (table == null)
         {
             if (fThrowException)
             {
                 throw ExceptionBuilder.ArgumentNull("table");
             }
             return false;
         }
         if (table.DataSet != this.dataSet)
         {
             if (fThrowException)
             {
                 throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
             }
             return false;
         }
         this.dataSet.OnRemoveTable(table);
         if ((table.ChildRelations.Count != 0) || (table.ParentRelations.Count != 0))
         {
             if (fThrowException)
             {
                 throw ExceptionBuilder.TableInRelation();
             }
             return false;
         }
         ParentForeignKeyConstraintEnumerator enumerator2 = new ParentForeignKeyConstraintEnumerator(this.dataSet, table);
         while (enumerator2.GetNext())
         {
             ForeignKeyConstraint foreignKeyConstraint = enumerator2.GetForeignKeyConstraint();
             if ((foreignKeyConstraint.Table != table) || (foreignKeyConstraint.RelatedTable != table))
             {
                 if (fThrowException)
                 {
                     throw ExceptionBuilder.TableInConstraint(table, foreignKeyConstraint);
                 }
                 return false;
             }
         }
         ChildForeignKeyConstraintEnumerator enumerator = new ChildForeignKeyConstraintEnumerator(this.dataSet, table);
         while (enumerator.GetNext())
         {
             ForeignKeyConstraint constraint = enumerator.GetForeignKeyConstraint();
             if ((constraint.Table != table) || (constraint.RelatedTable != table))
             {
                 if (fThrowException)
                 {
                     throw ExceptionBuilder.TableInConstraint(table, constraint);
                 }
                 return false;
             }
         }
         flag = true;
     }
     finally
     {
         Bid.ScopeLeave(ref ptr);
     }
     return flag;
 }
Esempio n. 7
0
        internal bool CanRemove(DataTable table, bool fThrowException)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTableCollection.CanRemove|INFO> {0}, table={1}, fThrowException={2}", ObjectID, (table != null) ? table.ObjectID : 0, fThrowException);
            try
            {
                if (table == null)
                {
                    if (!fThrowException)
                    {
                        return false;
                    }
                    throw ExceptionBuilder.ArgumentNull(nameof(table));
                }
                if (table.DataSet != _dataSet)
                {
                    if (!fThrowException)
                    {
                        return false;
                    }
                    throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
                }

                // allow subclasses to throw.
                _dataSet.OnRemoveTable(table);

                if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0)
                {
                    if (!fThrowException)
                    {
                        return false;
                    }
                    throw ExceptionBuilder.TableInRelation();
                }

                for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(_dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table) // we can go with (constraint.Table ==  constraint.RelatedTable)
                    {
                        continue;
                    }
                    if (!fThrowException)
                    {
                        return false;
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                for (ChildForeignKeyConstraintEnumerator constraints = new ChildForeignKeyConstraintEnumerator(_dataSet, table); constraints.GetNext();)
                {
                    ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                    if (constraint.Table == table && constraint.RelatedTable == table)
                    {
                        continue;
                    }

                    if (!fThrowException)
                    {
                        return false;
                    }
                    else
                    {
                        throw ExceptionBuilder.TableInConstraint(table, constraint);
                    }
                }

                return true;
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }