asp.net - NHibernate - how to handle user sessions -
I think what I'm doing here is a quick example of how to do it. It's okay to work properly with me, I can create new records with no problems, and do not read any problems in existing records. The problem I am facing is with the asp.net user session and how do I handle this fact in the middle of the load of that page, and I want to write it sometimes in the database.
When I try to write back to user object (complete with new address), I get an error That the user object is already connected to an existing session. I am using the code below to exclude the user from asp.net sessions, add the address and return it back to the database. It is just at that point where it hits. When things go wrong, the know-how are completely connected.
Zero AddAddress_Click (Object Sender, EventArgs E) {var session = Global.SessionFactory .GetCurrentSession (); User user = (user) HttpContext.Current.Session ["user"]; User.AddAddress (txtDescription.Text, txtLine1.Text, txtLine2.Text, txtTown.Text, txtCounty.Text, txtPostCode.Text, txtCountry.Text); Session.SaveOrUpdate (user); Session.Flush (); }
Please ignore the 101 ways for which maybe it is probably wrong, I know it well. I just want to do some work to prove myself that NHibernate is the road ahead for this project, so it will be a bit quicker and dirty in the moment.
Using a normal practice single eSession
per request is possible with the NHibernate, otherwise it may be called" Open session in view "or Is known as "OSI" and see.
Comments
Post a Comment