如何在 MVP 中保存对象流畅的NHibernate

发布于 2024-11-06 21:00:32 字数 605 浏览 3 评论 0原文

我刚刚在一个新项目中接到一个任务,该任务是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野鹿林 2024-11-13 21:00:32

使用NHibernate的cascade属性。请参阅此示例(尤其是第 20.3 部分)。

Use NHibernate's cascade attribute. See this example (especially part 20.3).

世态炎凉 2024-11-13 21:00:32

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文