Sql – Does Linq to Sql have onChanging

asp.netasp.net-mvclinq-to-sql

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.

Best Solution

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...
    }
}