tags:

views:

59

answers:

2

SubSonic provides the overrideable methods BeforeUpdate and BeforeInsert for doing validation. Is there a way to hook into the BeforeDelete event, if such a thing even exists?

A: 

I am not aware of any BeforeDelete event but you could always override the Delete method and handle it there. Just remember to put any overridden methods in a seperate file(SubSonic classes are partial) the convention is to put that file in an "Altered" folder and handle that there.

runxc1 Bret Ferrier
A: 

From what I remember, objects don't have a Delete method. You need to delete via a controller (at least in my templates!).

In my templates, I have methods PreDelete/PostDelete, PreDestroy/PostDestroy. We may have added these ourselves.

Take a look at this article with some sample code: http://blog.lavablast.com/post/2008/08/SubSonic-v21-Controller-and-Utilities.aspx (we have other articles on the same controllers on our blog - but they were for v2.0).

Jason Kealey