This is a mirror of official site: http://jasper-net.blogspot.com/

Fluent NHibernate Tutorial (C#)

| Tuesday, May 11, 2010
In this tutorial we are going to create a simple ORM (Object relational mapping) application using Fluent NHibernate 1.0 RTM which is external to the NHibernate Core, but is fully compatible with NHibernate version 2.1, and is experimentally compatible with NHibernate trunk.

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents (.hbm.xml files), Fluent NHibernate lets you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.

How does Fluent NHibernate work?
- It moves your mappings into actual code, so they're compiled along with the rest of your application
- Rename refactorings will alter your mappings just like they should, and the compiler will fail on any typos
- It has a conventional configuration system, where you can specify patterns for overriding naming conventions and many other things
- you set how things should be named once, then Fluent NHibernate does the rest

For more info, click the following link: http://wiki.fluentnhibernate.org/

GETTING STARTED:
First thing you need to download NHibernateFluent libraries that can be found here: http://fluentnhibernate.org/
Unzip downloaded file and extract it into a folder of your choice.

Now start Visual Studio and create new windows application project. I named it SimpleOrmApplication. First of all we are going to reference some dll files that Fluent NHibernate needs. Right click on the References in your solution explorer and select Add Reference. Navigate to directory where you have previously extracted your Fluent NHibernate libraries and reference the following dll files:

- FluentNhibernate.dll
- NHibernate.dll
- NHibernate.ByteCode.Castle


Read more: </dream-in-code>

Posted via email from jasper22's posterous

0 comments: