开发者

How to save objects in MVP + Fluent NHibernate

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: s开发者_运维百科ave 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.


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


Fluent NHibernate simplifies the things. Refer Sharp Architecture, it is one of the best places to learn good practices for NHibernate and Repositories.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜