When calling ITopicRepository.Delete(), any topic references on the current or descendent topics should be deleted as part of the operation. While this will be done by e.g. the DeleteTopic stored procedure (if using the SqlTopicRepository), this should also be done in the in-memory topic graph in order to ensure that any topics they are pointing to no longer maintain a reference to the deleted topics via IncomingRelationships. There is already logic in place to handle this, but it throws an exception.
Cause
The Delete() method loops through all items in the Topic.References collection, and removes them, thus not only removing them from the current collection, but also any IncomingRelationships that point back to the current topic. By removing them, however, the collection being iterated against is modified, resulting in an exception being thrown.
When calling
ITopicRepository.Delete(), any topic references on the current or descendent topics should be deleted as part of the operation. While this will be done by e.g. theDeleteTopicstored procedure (if using theSqlTopicRepository), this should also be done in the in-memory topic graph in order to ensure that any topics they are pointing to no longer maintain a reference to the deleted topics viaIncomingRelationships. There is already logic in place to handle this, but it throws an exception.Cause
The
Delete()method loops through all items in theTopic.Referencescollection, and removes them, thus not only removing them from the current collection, but also anyIncomingRelationshipsthat point back to the current topic. By removing them, however, the collection being iterated against is modified, resulting in an exception being thrown.