The entire tree is loaded in one session which is then closed. When a node's title is changed, a new session is opened for the specific purpose of persisting the title change. So is Update() appropriate to this scenario?
jchapman wrote:
If your object is not associate with a session, I would suggest loading your object you want to change first, making the modification you want and then flushing the session. That way only the changed records will need to be persisted.
I tried your suggestion with the following code:
Code:
session = SessionFactory.OpenSession();
Category c = session.Get<Category>( editedCategory.ID );
c.Title = editedCategory.Title;
session.Flush();
session.Close();
Is this what you had in mind? There's only one UPDATE that occurs, as you said, but
wow there sure are a lot of SELECT statements. It doesn't look to me to be more efficient this way. What do you think?