I have a Linq-to-SQL class, and I'd like to perform some pre-save validation before the record is persisted to the DB. In addition, once it has been saved, I'd like to have some post-save processing code.
Similarly, when a record is deleted, I'd like to have pre- and post- methods that will be called, no matter from where the context.SubmitChanges()
call is made.
I don't see any methods in the generated code that I can override. The partial method OnValidate()
may be sufficient for the pre-processing, but I want to ability to cancel the save if certain conditions are not met, and I don't see any hooks at all for post-processing.
Am I missing something? Or can you recommend another way of achieving the intended effect?
Thanks!