Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CanRemove() [1/2]

bool System.Data.DataTableCollection.CanRemove ( [NotNullWhen(true)] DataTable table,
bool fThrowException )
inlinepackage

Definition at line 327 of file DataTableCollection.cs.

328 {
329 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTableCollection.CanRemove|INFO> {0}, table={1}, fThrowException={2}", ObjectID, table?.ObjectID ?? 0, fThrowException);
330 try
331 {
332 if (table == null)
333 {
334 if (!fThrowException)
335 {
336 return false;
337 }
338 throw ExceptionBuilder.ArgumentNull("table");
339 }
340 if (table.DataSet != _dataSet)
341 {
342 if (!fThrowException)
343 {
344 return false;
345 }
346 throw ExceptionBuilder.TableNotInTheDataSet(table.TableName);
347 }
348 _dataSet.OnRemoveTable(table);
349 if (table.ChildRelations.Count != 0 || table.ParentRelations.Count != 0)
350 {
351 if (!fThrowException)
352 {
353 return false;
354 }
355 throw ExceptionBuilder.TableInRelation();
356 }
357 ParentForeignKeyConstraintEnumerator parentForeignKeyConstraintEnumerator = new ParentForeignKeyConstraintEnumerator(_dataSet, table);
359 {
360 ForeignKeyConstraint foreignKeyConstraint = parentForeignKeyConstraintEnumerator.GetForeignKeyConstraint();
361 if (foreignKeyConstraint.Table != table || foreignKeyConstraint.RelatedTable != table)
362 {
363 if (!fThrowException)
364 {
365 return false;
366 }
367 throw ExceptionBuilder.TableInConstraint(table, foreignKeyConstraint);
368 }
369 }
370 ChildForeignKeyConstraintEnumerator childForeignKeyConstraintEnumerator = new ChildForeignKeyConstraintEnumerator(_dataSet, table);
372 {
373 ForeignKeyConstraint foreignKeyConstraint2 = childForeignKeyConstraintEnumerator.GetForeignKeyConstraint();
374 if (foreignKeyConstraint2.Table != table || foreignKeyConstraint2.RelatedTable != table)
375 {
376 if (!fThrowException)
377 {
378 return false;
379 }
380 throw ExceptionBuilder.TableInConstraint(table, foreignKeyConstraint2);
381 }
382 }
383 return true;
384 }
385 finally
386 {
387 DataCommonEventSource.Log.ExitScope(scopeId);
388 }
389 }
virtual void OnRemoveTable(DataTable table)
Definition DataSet.cs:2617

References System.Data.DataTableCollection._dataSet, System.Data.ExceptionBuilder.ArgumentNull(), System.Data.DataTable.ChildRelations, System.Data.InternalDataCollectionBase.Count, System.Data.DataTable.DataSet, System.Data.DataCommonEventSource.Log, System.Data.DataTableCollection.ObjectID, System.Data.DataSet.OnRemoveTable(), System.Data.DataTable.ParentRelations, System.Data.ExceptionBuilder.TableInConstraint(), System.Data.ExceptionBuilder.TableInRelation(), System.Data.DataTable.TableName, and System.Data.ExceptionBuilder.TableNotInTheDataSet().