How to perform cascade delete in CSLA?

How to perform cascade delete in CSLA?

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


Zubair posted on Thursday, June 14, 2012

Hi

 

I want to perform cascade delete using CSLA only, suppose I m passing deleting employee table record then it should deleted record from all the table where  that empid is used.

 

eagerly waiting for your reply

 

Thanks

JonnyBee replied on Thursday, June 14, 2012

Hi,

The only safe way is to use "cascading delete" on relationships in the database.

Zubair replied on Thursday, June 14, 2012

HI

Thanks for your quick reply, so that means we cant perform cascade delete from code behind using CSLA classes?

JonnyBee replied on Thursday, June 14, 2012

Uhm, well you can do cascade delete but YOUR code must handle the deletion by either making sure to load ALL child objects and marks as Deleted ot traverse the entire tree and call delete in the data access layer.

If you have a rich client and lazy load child objects this can be a real PITA.

So my recommended way is to use cascading delete in the database.

 

Copyright (c) Marimer LLC