cascade deletetes and child objects

cascade deletetes and child objects

Old forum URL: forums.lhotka.net/forums/t/3540.aspx


jhw posted on Friday, September 14, 2007

When we delete a root object we mark it as new as it no longer is in the db.

If the root object has children that are deleted through cascade deletes, should we just expose the markNew sub as a friend or is there a different recommended system for csla.

The database already exists, and the cascade deleted already are in place. It seems like a lot of extra processing to manually delete the children instead of just letting the cascade deletes do the work. Is there any good reason not to let the cascade deletes do there work, and just expose the markNew method?

 

Heath

RockfordLhotka replied on Friday, September 14, 2007

My recommendation is to do the cascade deletes at the database level (or do it via sprocs).

At the object level, I usually just clear the child references. So if the root has a list of children, I'll just create a new, blank, list object to replace the old one. No sense setting properties on child objects - their data is gone, they are gone, so just get rid of them.

Protected Overrides Sub DataPortal_DeleteSelf()
  ' delete root data
  _childList = MyChildListType.NewList()
  MarkNew()
End Sub

 

Copyright (c) Marimer LLC