Asp.net mvc equivalent of rails before_save callback
1 answer
If you are using Entity Framework (which your tag points to) then fooobar.com/questions/1701796 / ... should help you. Basically you can intercept the SavingChanges event and do whatever you want. Put this in a partial class that adds the following methods to the context of your object:
partial void OnContextCreated()
{
SavingChanges += DoWhatYouMust;
}
private void DoWhatYouMust(object sender, System.EventArgs e)
{
}
+3
a source to share