Let Fluent-Nhibernate handle Nhibernate mapping..

In my previous post I have talk about Nhibernate and NHibernate Mapping.  As i have already realized the power of Nhibernate , and  I have dug it down  more and more . Will everything works like charm but I personally found to create mapping file for all the entities/object.  So I have decided to look for some  more relevent solution so that  I really can avoid this mapping step while working on my appplicaiton.

Fluent Nhibernet is the answer of my problem .Fluent nhibernate is an auto mapper which create mapping of your objects with the database table columns. We really do not have to worry about the mapping now and we can concentrate more on writing better application. You can download Fluent Nhibernate from here . I am also attaching sample business model to use Fluent Nhibernate . You can download  code form here .


You need to reference some libraries as below .

using FluentNHibernate;

using NHibernate;

using FluentNHibernate.Cfg;

using FluentNHibernate.Cfg.Db;

using FluentNHibernate.Automapping;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Criterion;




I have wrapped the use of Nhibernate in Repository . It really adds more power and flexibility to the application when Nhibernate is used with Repository pattern.

Note that i have used the namespace “FluentNhibernateSampleORM.Model” Now Fluent Nhibernate will pick up all the objects under this namespace automatically and map it to the database .

Reference: http://wiki.fluentnhibernate.org/Getting_started



2 thoughts on “Let Fluent-Nhibernate handle Nhibernate mapping..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s