views:

54

answers:

1

Hi i'm looking for a asp.net mvc callback for elaborate data before save a model.

In rails there is before_save.

Thanks

+1  A: 

If you are using Entity Framework (which your tag indicates), then this StackOverflow post should be able to help you out. Basically you can intercept the SavingChanges event, and do whatever you want. Put this in a partial class that adds the following methods to your object context:

partial void OnContextCreated()
{
    SavingChanges += DoWhatYouMust;
}

private void DoWhatYouMust(object sender, System.EventArgs e)
{
}
Thomas