protected OnRemoveTable ( |
||
table | ||
Résultat | void |
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); } }
internal bool CanRemove([NotNullWhen(true)] 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); } }