问题
You can easily use the PropertyChanges events to set the flag. But how do you easily reset it after a save to the ObjectContext?
回答1:
what about the ObjectContext.SavingChanges event? See also http://www.thedatafarm.com/blog/2008/07/13/OverridingObjectContextSaveChanges.aspx.
回答2:
The above method calls for using the SavingChanges event which is called before the changes are persisted. If there is an error during the save, you have already cleared your dirty flag. I would think there would be a SavedChanges event exposed as well.
来源:https://stackoverflow.com/questions/16406/best-way-to-implement-a-dirty-flag-in-ef