如何在 MVP 中保存对象流畅的NHibernate
我刚刚在一个新项目中接到一个任务,该任务是使用 MVP、Fluent NHibernate 实现的。
Model - Enitity- Office, OfficeRepository, OfficeCommand
Presenter - OfficeSettingsPresenter
View - IOfficeSettingsView, OfficeSettings.aspx, OfficeSettings.aspx.cs
Office 有一些子对象以及许多其他值类型属性。
对 Office 及其子对象的更改当前以这种方式保存:如果对 Office 的子对象进行更改,则该更改将独立于 Office 对象保存。保存对象时,仅保存值属性,因为其子对象已单独保存。
理想情况下,它应该将对象保存为:如果发现 Office 中的任何一个对象脏了,则将 Office 及其子对象保存起来。
我应该使用什么方法来进行上述更改,以便根据对象状态是否脏来将对象及其子对象作为一个整体保存?
此外,网络链接也会非常有帮助。
I have just got a task in a new project which is implemented using MVP, Fluent NHibernate.
Model - Enitity- Office, OfficeRepository, OfficeCommand
Presenter - OfficeSettingsPresenter
View - IOfficeSettingsView, OfficeSettings.aspx, OfficeSettings.aspx.cs
Office has some child objects along with many other value type properties.
Changes to Office and its child objects are currently saved in this way: If a change is made to Office's child object, it is saved independently from the Office object. When object is saved, only value properties are being saved as its child object are already being saved separately.
Ideally, it should save the object as: save the Office along with its child object if any of them is found dirty.
What approach should I use to make the above change so object is saved as a whole along with its child objects depending on whether an object state is dirty or not?
Also, a weblink would be really helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用NHibernate的cascade属性。请参阅此示例(尤其是第 20.3 部分)。
Use NHibernate's cascade attribute. See this example (especially part 20.3).
Fluent NHibernate 简化了事情。
请参阅 Sharp Architecture,它是学习良好实践的最佳场所之一
NHibernate 和存储库。
Fluent NHibernate simplifies the things.
Refer Sharp Architecture, it is one of the best places to learn good practices for
NHibernate and Repositories.