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

◆ CanRemove() [1/2]

bool System.Data.DataColumnCollection.CanRemove ( DataColumn column,
bool fThrowException )
inlinepackage

Definition at line 357 of file DataColumnCollection.cs.

358 {
359 if (column == null)
360 {
361 if (!fThrowException)
362 {
363 return false;
364 }
365 throw ExceptionBuilder.ArgumentNull("column");
366 }
367 if (column._table != _table)
368 {
369 if (!fThrowException)
370 {
371 return false;
372 }
373 throw ExceptionBuilder.CannotRemoveColumn();
374 }
377 {
378 if (!fThrowException)
379 {
380 return false;
381 }
382 throw ExceptionBuilder.CannotRemovePrimaryKey();
383 }
384 for (int i = 0; i < _table.ParentRelations.Count; i++)
385 {
386 if (_table.ParentRelations[i].ChildKey.ContainsColumn(column))
387 {
388 if (!fThrowException)
389 {
390 return false;
391 }
392 throw ExceptionBuilder.CannotRemoveChildKey(_table.ParentRelations[i].RelationName);
393 }
394 }
395 for (int j = 0; j < _table.ChildRelations.Count; j++)
396 {
397 if (_table.ChildRelations[j].ParentKey.ContainsColumn(column))
398 {
399 if (!fThrowException)
400 {
401 return false;
402 }
403 throw ExceptionBuilder.CannotRemoveChildKey(_table.ChildRelations[j].RelationName);
404 }
405 }
406 for (int k = 0; k < _table.Constraints.Count; k++)
407 {
408 if (_table.Constraints[k].ContainsColumn(column))
409 {
410 if (!fThrowException)
411 {
412 return false;
413 }
414 throw ExceptionBuilder.CannotRemoveConstraint(_table.Constraints[k].ConstraintName, _table.Constraints[k].Table.TableName);
415 }
416 }
417 if (_table.DataSet != null)
418 {
419 ParentForeignKeyConstraintEnumerator parentForeignKeyConstraintEnumerator = new ParentForeignKeyConstraintEnumerator(_table.DataSet, _table);
421 {
422 Constraint constraint = parentForeignKeyConstraintEnumerator.GetConstraint();
423 if (((ForeignKeyConstraint)constraint).ParentKey.ContainsColumn(column))
424 {
425 if (!fThrowException)
426 {
427 return false;
428 }
429 throw ExceptionBuilder.CannotRemoveConstraint(constraint.ConstraintName, constraint.Table.TableName);
430 }
431 }
432 }
433 if (column._dependentColumns != null)
434 {
435 for (int l = 0; l < column._dependentColumns.Count; l++)
436 {
437 DataColumn dataColumn = column._dependentColumns[l];
438 if ((_fInClear && (dataColumn.Table == _table || dataColumn.Table == null)) || dataColumn.Table == null)
439 {
440 continue;
441 }
442 DataExpression dataExpression = dataColumn.DataExpression;
443 if (dataExpression != null && dataExpression.DependsOn(column))
444 {
445 if (!fThrowException)
446 {
447 return false;
448 }
449 throw ExceptionBuilder.CannotRemoveExpression(dataColumn.ColumnName, dataColumn.Expression);
450 }
451 }
452 }
453 foreach (Index liveIndex in _table.LiveIndexes)
454 {
455 }
456 return true;
457 }
void OnRemoveColumnInternal(DataColumn column)
UniqueConstraint _primaryKey
Definition DataTable.cs:124
ConstraintCollection Constraints
Definition DataTable.cs:332
DataRelationCollection ParentRelations
Definition DataTable.cs:572
DataRelationCollection ChildRelations
Definition DataTable.cs:324
List< Index > LiveIndexes
Definition DataTable.cs:269
bool ContainsColumn(DataColumn column)
Definition DataKey.cs:117

References System.Data.DataColumnCollection._fInClear, System.Data.DataTable._primaryKey, System.Data.DataColumnCollection._table, System.Data.ExceptionBuilder.ArgumentNull(), System.Data.ExceptionBuilder.CannotRemoveChildKey(), System.Data.ExceptionBuilder.CannotRemoveColumn(), System.Data.ExceptionBuilder.CannotRemoveConstraint(), System.Data.ExceptionBuilder.CannotRemoveExpression(), System.Data.ExceptionBuilder.CannotRemovePrimaryKey(), System.Data.DataTable.ChildRelations, System.Data.Constraint.ConstraintName, System.Data.DataTable.Constraints, System.Data.DataKey.ContainsColumn(), System.Data.InternalDataCollectionBase.Count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Data.DataTable.DataSet, System.Data.UniqueConstraint.Key, System.Data.DataTable.LiveIndexes, System.Data.DataTable.OnRemoveColumnInternal(), System.Data.DataTable.ParentRelations, System.Data.Constraint.Table, System.Data.ConstraintCollection.Table, and System.Data.DataTable.TableName.