I still have difficulties with some NHibernate terms so please bear with me.
I am building a POCO class based off a web submission. The web user will be changing some scalar properties. The POCO will already be persisted in the database. I want to save changes to the POCO to the database, collect the child objects (which should be unchanged) and return the POCO’s graph so I can send feedback back to the user.
What is the proper way to do this? Is this “detached”? What is the appropriate method for connecting the child collection? Can it be done in one database batch?
Session.Update().Fetch()method.For example-
var users = QueryOver<User>().Where(u => u.Age > 18).Fetch(u => u.Children).Eager.In general, for a web app, I would recommend reading a little about the ‘session per request’ pattern. (this example is a little bit of an overkill for my taste, but it explains the concept quite well).
Also don’t forget to always use transactions.