O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Opening a session

Our application needs a session object to communicate with the database when writing or reading data. As mentioned above, session objects can only be obtained through a session factory. Once we have constructed a session factory, opening a session is a quick and cheap operation. After we have finished using our session object, we must not forget to close the session and dispose it. We can use a using statement to instruct the compiler to do this automatically for us.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required