在EF中实现脏标志的最佳方法 [英] Best way to implement a dirty flag in EF

查看:119
本文介绍了在EF中实现脏标志的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以轻松地使用 PropertyChanges 事件来设置标志。但是保存到 ObjectContext 之后如何轻松地将其重置?

You can easily use the PropertyChanges events to set the flag. But how do you easily reset it after a save to the ObjectContext?

推荐答案

<上面的方法要求使用SavingChanges事件,该事件在更改被持久保存之前被调用。如果保存期间出错,则您已经清除了脏标志。我认为也会有一个SavedChanges事件。

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.

这篇关于在EF中实现脏标志的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆