This question is locked. New answers and comments are not allowed.
I'm using a reverse mapping on a project. I have a class that exposes a collection of another class type. When I use .remove(objectInstance) on the collection property I am able to remove from the working collection, but the change does not persist to the database.
To go a little deeper, I have two rad list boxes. I'm adding new selections and deleting unselected elements on save.
My underlying code uses the parent collection property to add new elements:
parentObject.Children.Add(childObjectToAdd) |
And .Remove() to remove unselected elements:
parentObject.Children.Remove(childObjectToRemove) |
After looping through I call:
scopeInstance.Add(parentObject) scopeInstance.Transaction.Commit() |
The newly added object linkages save. But the removed linkages do not delete. The only way I can get it to work is to delete the child object via the scope:
parentObject.Children.Remove(childObjectToRemove) scopeInstance.Remove(childObjectToRemove) |
Since I'm checking my children collection for object existence repeatedly, if I only delete via scopeInstance.Remove(..) and not parentObject.Children.Remove(..) I get an error about attempting to read/write elements marked for deletion.
Is there another way to go about persisting .Remove() calls for a child collection property?