protected override void RemoveCore(DataRelation relation) { base.RemoveCore(relation); _dataSet.OnRemoveRelationHack(relation); relation.SetDataSet(null); relation.ChildKey.GetSortIndex().RemoveRef(); if (relation.Nested) { relation.ChildTable.CacheNestedParent(); } for (int i = 0; i < _relations.Count; i++) { if (relation == _relations[i]) { _relations.RemoveAt(i); ((DataTableRelationCollection)(relation.ParentTable.ChildRelations)).Remove(relation); // Remove Cache from ParentTable -> ChildRelations ((DataTableRelationCollection)(relation.ChildTable.ParentRelations)).Remove(relation); // Removing Cache from ChildTable -> ParentRelations if (relation.Nested) { relation.ChildTable.CacheNestedParent(); } UnregisterName(relation.RelationName); relation.SetParentKeyConstraint(null); relation.SetChildKeyConstraint(null); return; } } throw ExceptionBuilder.RelationDoesNotExist(); }