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

Time for action – Creating a session and doing some CRUD

After all this theory, let's now implement a sample. In this exercise, we will define a simple model and use auto-mapping to map the model. We will then create a session factory which provides us with session objects. We will use different session objects to write data to and read data from the database.

  1. Open SMSS and log in to your local .\SQLEXPRESS database.
  2. Define a new empty database called NHibernateSessionSample.
  3. Open Visual Studio and create a new Console Application project. Call the project NHibernateSessionSample.
  4. To the project, add references to the NHibernate, NHibernate.ByteCode.Castle, and FluentNHibernate assemblies located in the lib folder, as shown in the following screenshot: ...

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