Tag Archives: nhibernate

Asp.Net & ORM Tool NHibernate For Dummy Tutorial – Update & Delete Operation

NHibernate is a open source Object-Relational Mapping (ORM) tool. This ORM tool hides sql query complexities by replacing query with mapping and class object.

I already have article about basic NHibernate in previous post. If you are new to Nhibernate then I recommend to Click here Asp.Net & ORM Tool NHibernate For Dummy Tutorial – Select & Insert Operation first.

Lets recap what we have to do to work with NHibernate.

  1. Download necessary NHibernate file including NHibernate.dll & configuration template/example at http://sourceforge.net/projects/nhibernate
  2. Create xml mapping file and a class which representates DB table
  3. Include Nhibernate dll file, NHibernate xml configuration file, class library (if you have separate class project), and Asp.Net file it self
  4. Write codes inside the Asp.Net file that contains NHibernate configuration class object initialization, AddAssembly to Class Library, BuildSessionFactory, OpenSession, BeginTransaction, SaveOrUpdate, Commit to save data to DB.
  5. Write SQL Query replacement with QueryOver<T>() method and Where filter (if necessary) that has LinQ like syntax to retrieve record(s) and automatically convert to a class

Continue reading

Asp.Net & ORM Tool NHibernate For Dummy Tutorial – Select & Insert Operation

NHibernate is a open source Object-Relational Mapping (ORM) tool. This ORM tool hides sql query complexities by replacing query with mapping and class object.
Every .Net Project can use Nhibernate to work with database.

The purpose of NHibernate is to save developers work time thus increasing productivity. Large application may get more benefit from NHibernate than small app.

This blog post gives Asp.Net & NHibernate dummy examples. These examples cover select / retrieve records and insert a new record.

First thing first, we need to download Nhibernate files. Please download the zip file from http://sourceforge.net/projects/nhibernate/

As a brief, we need xml mapping file, a class which representates DB table, Nhibernate dll file, NHibernate xml configuration file, and Asp.Net file it self that contains NHibernate configuration object, NHibernate session etc to provide data to UI.

I use VS 2010 Express & SQL Server 2008 R2 to build this example.
Continue reading