views:

230

answers:

1

Ok. So the situation is:

Parent Class which has an IDictionary of Child Classes. I wish these child classes to be deleted when the parent class is. This works fine. I also wish to be able to delete members of the child class individually, and this does NOT work.

So my Question is; Why can I not delete these child members?

The error I get is along the lines of:

Cannot delete, Would be readded by cascade

My mapping file in the parent class has a cascade setting of 'all-delete-orphan' while the child class has no cascading defined.

Any idea? Cheers.

+2  A: 

It would be helpful to see the mappings. But my guess is that you are not removing the child from the parent's collection in addition to deleting it.

Jamie Ide
Was a variant on this. Cheers! (Basically, I should have been removing it from collection and saving the parent object)
Damien
That worked because you had it set to all-delete-orphan. If you hadn't set that, you would have had to explicitly delete the child object so it wouldn't become orphaned. Glad you were able to figure it out.
Jamie Ide