Best way to implement a dirty flag in EF

╄→尐↘猪︶ㄣ 提交于 2020-01-15 10:28:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!