持久化和回滚,模型,C#
我不久前问了一个关于回滚的问题,我有一个新的相关问题,我有答案,但想要一些意见。
所以我正在构建一个持久性无知的对象模型,现在我正在考虑回滚。我研究了 nHibernate 如何管理它,这表明如果我希望能够取消未保存的更改,我需要在域对象上有自己的实现。
所以我在 ComponentModel 中看到了 IEditableObject ,它简洁地描述了问题。伴随描述的微软示例几乎就是我会做的,他们有一个包含实际数据的私有结构,当数据更改时,将保存原始数据并创建一个新数据。它和 INotifyPropertyChanged 一起通知对象已重置。
有人做过类似的事情吗?你能建议一个更好的模式吗?
I asked a little while ago a question about rollback, I have a new related question that I have an answer to, but would like some input.
So I'm building a persistence ignorant object model and I'm now thinking about roll back. I've looked at how nHibernate manages it, and that suggests that I'll need to have my own implementation on the domain objects if I want to be able to cancel unsaved changes.
So I've seen IEditableObject in ComponentModel which succinctly describes the problem. Microsoft's example that goes along with the description is pretty much what I would have done, they have a private struct which contains the actual data, and when the data is changed the original is saved and a new one is created. That and INotifyPropertyChanged to notify that the object has reset.
Has anyone done anything similar? Can you suggest a better pattern?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您阅读 Rocky Lhotka 关于他的框架 CSLA.NET 的一些内容: http://www.lhotka.net /。我不确定我是否建议实际使用它,但他非常彻底地介绍了回滚和业务对象数据一致性等内容。
I'd suggest you read some of Rocky Lhotka's stuff on his framework, CSLA.NET: http://www.lhotka.net/. I am not sure I'd recommend actually using it, but he covers things like rollback and business object data consistency quite thoroughly.