Proper Way to Delete Child Object

Proper Way to Delete Child Object

Old forum URL:

acgritt posted on Tuesday, March 17, 2015

I am wondering what is the proper way to delete a child object.  We have a Borrower object that has an Address object as a child.  Under a certain case we want to delete the Address object.  We have found that if we MarkDeleted on the child object, when saving it does the Delete and then it returns the Parent with a NEW Address with the same properties.  After looking at the code (CSLA I find in the ChildDataPortal.cs after it does the Child_DeleteSelf call it then calls MarkNew().  I am assuming that this is what is causing this behavior.  This leads me to the question of what is the correct way to delete the child object and remove it from the parent object when saving the parent.

JonnyBee replied on Tuesday, March 17, 2015


So you have a 1:1 relationship on these business objects? 

Then it is up to your data access code to re-initilalize the child object with a new object after the Delete.

If it was a parent-list-child it would be handled correctly by the list. 

Copyright (c) Marimer LLC