Reputation: 10888
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.
Upvotes: 0
Views: 253
Reputation: 6742
Use NHibernate's cascade attribute. See this example (especially part 20.3).
Upvotes: 1
Reputation: 801
Fluent NHibernate simplifies the things. Refer Sharp Architecture, it is one of the best places to learn good practices for NHibernate and Repositories.
Upvotes: 0