SavedChanges event in EF
SavingChanges event of DBCont开发者_运维百科ext fires just before saves are sent to DB.
Is there an event somewhere I can subscribe which fires just AFTER save is complete ?
The short answer is no - there is no such event.
More context regarding what exactly you are trying to achieve and why you want such an event could help in giving a better answer.
A workaround that comes to mind would be overriding the SaveChanges
method and executing your custom code (or raising your event) after the call to base.SaveChanges()
. Basically you can do something like in this example, but get it to suit your needs, e.g.:
public override int SaveChanges(SaveOptions options)
{
int result = base.SaveChanges(options);
// Do whatever you need to do after saving changes
return result;
}
精彩评论