tags:

views:

234

answers:

1

I want to implement this partial method in my Linq table class.

partial void OnValidate(System.Data.Linq.ChangeAction action);

My hope is that is it called right before an insert. Can anyone tell me when the OnValidate method is called?

Update 1

I understand that I can check the enum to see what action causes it to fire. But WHEN does it get called? I need to know if it gets called each time someone submits changes or what?

+4  A: 

The OnValidate method for each changed entity, if it exists, will be called during SubmitChanges for the data context containing the entity. It will, thus, fire for all inserts, updates, and deletes done with that data context since the last time SubmitChanges was called (or the context created). If you need to distinguish your validation actions depending on the type of change you can key off the ChangeAction parameter to control the flow of execution.

tvanfosson
Awesome just what I needed! Thanks!
Anthony D