views:

95

answers:

1

Hi

I am looking at this tutorial yet it uses the entity framework.

so I am wondering can I do the same thing with linq to sql and if so how? They seem to use this OnChaning thing but I don't know if linq to sql has it.

+2  A: 

The extensibility methods for the Changed/Changing events on each property are generated by the Linq to SQL designer. You just need to have a partial class implementation of the entity that implements the extensibilty methods.

public partial class Entity
{
    public partial void OnIDChanging( int value )
    {
       ... some validation code...
    }
}
tvanfosson
So I can do what the tutorial has with linq to sql?
chobo2
Yes. I didn't look at the tutorial in depth, but as far as the extensibility methods are concerned you should be ok.
tvanfosson
Just did a quick test and tvanfosson is correct. The On___Changing event will fire when the system detects a change to the property on a submit.
griegs