views:

117

answers:

2

For example i have two entities. "RealEstate" and "Picture". RealEstate holds a collection of Picture. In the mapping file RealEstate has a bag in it for Pictures and cascade is Delete".

If you delete a RealEstate all the related Pictures will be deleted. But is there any way to execute a custom method to delete the pictures from the web server.

I did it by assigning cascade="none" and when i delete a RealEstate i first check is there any Pictures related to it, if there is, i call DeletePicture() method for it.

I am curious about what do you do in these kind of situations ?

Thanks

+2  A: 

You could write an interceptor and implement the OnDelete method that will be executed when a picture is deleted.

Darin Dimitrov
Thank you i will check it as soon as possible and mark it as answer,Thanks again
Barbaros Alp
+1  A: 

If you're using nhibernate 2.0 , the new and better way to go is : use events.

Article about nhibernate 2.0 events

sirrocco
Thanks for the great info
Barbaros Alp

related questions