Hi,
The architecture that I have adopted for my application is as follows:
Domain
ServiceLayer
UI
The service layer class contain methods to add and update certain types of domain entities and these are passed in as objects to the methods.
Some objects that I want to update contain collections of child objects and it is possible that only some or none of the children have *actually* been changed. However, I still pass in the parent object into the Update method and then call the Session.Update on the parent and children as I am not sure which objects were changed in the UI, e.g.
public void Update(Order order) { ... this._session.Save(order); foreach (OrderLine line in order.Lines) { this._session.Save(line); } ... }
In my tests, it seems that NH is smart enough to know that if I call Update on the session for an object that hasn't really changed since being loaded then it won't actually generate SQL against the DB...nice!! Saves me having to worry about tracking an objects dirty status.
Is this an OK design or is there something that I am missing here? Is there a better way to be coding my service layer?
Thanks,
Jason
|