如何撤消对自我跟踪实体所做的所有更改?
我有一个客户端应用程序,可以通过 WCF 下载许多 STE。
使用 WPF 应用程序,用户可以从列表框中选择一个实体,并通过弹出的用户控件对其进行编辑。由于 UserControl 直接绑定到对象,因此当用户进行更改时,它当然会影响该对象。
我想提供一个取消功能,它将撤消对实体所做的所有更改。
有什么想法吗?
I have a client application that downloads a number of STE's via WCF.
Using a WPF application, users can select an entity from a ListBox, and edit it via a popup UserControl. As the UserControl is bound directly to the object, when a user makes a change it of course affects the object.
I would like to provide a Cancel function which will undo all changes made to the entity.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以保留该实体的原始副本。并编辑它的克隆版本。
如果用户取消更改,您只需继续使用原始副本即可。
You can keep a original copy of the entity. And edit a cloned version of it.
If the user cancels the changes you simply keep using the original copy.
我想说的是,当您在绑定的 PropertyChanged 事件中使用 WPF 时,会保存一个带有键 PropertyName 和值 PropertyValue 的字典。并在使用反射恢复状态后
I would say as you use WPF just in binded PropertyChanged event save a Dictionary with key PropertyName and value PropertyValue. And after restore the state by using reflection
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/c12bd8c8-231f-4dcc-a665-b048f7debbd7/
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/c12bd8c8-231f-4dcc-a665-b048f7debbd7/
到目前为止我正在使用这个解决方案
扩展方法
主要代码
I'm using this solution so far
Extension method
Main code