Article series on NHibernate and Fluent NHibernate – Part 3

Today the third part of my series on NHibernate and Fluent NHibernate went live. You can read it here.

Summary

In part 3 of this article series about NHibernate and Fluent NHibernate I have discussed how to let Fluent NHibernate automatically map a domain model to a data model. We have realized that FNH provides a reasonable mapping out of the box by using default conventions. I have shown how one can implement user defined conventions which will influence how the mapping is defined on a very fine grained level. I have also shown that if we use a base class in our domain which implements common functionality we can instruct FNH to ignore this class and just map the “real” entities.

FNH with its auto mapping feature reduces the task of mapping a complex domain to an underlying data model to just a few keystrokes. And as is always true: less code results in less bugs and less maintenance overhead.

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

About Gabriel Schenker

Gabriel N. Schenker started his career as a physicist. Following his passion and interest in stars and the universe he chose to write his Ph.D. thesis in astrophysics. Soon after this he dedicated all his time to his second passion, writing and architecting software. Gabriel has since been working for over 12 years as an independent consultant, trainer, and mentor mainly on the .NET platform. He is currently working as chief software architect in a mid-size US company based in Austin TX providing software and services to the pharmaceutical industry as well as to many well-known hospitals and universities throughout the US and in many other countries around the world. Gabriel is passionate about software development and tries to make the life of developers easier by providing guidelines and frameworks to reduce friction in the software development process. Gabriel is married and father of four children and during his spare time likes hiking in the mountains, cooking and reading.
This entry was posted in Fluent NHibernate, How To, NHibernate, tutorial. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://blog.coreycoogan.com Corey Coogan

    Thanks for the article series Gabriel. I’ve recently jumped into both NH and FNH via a personal project I’m doing with the S#arpArchitecture for RoomParentsOnline.com.

    One thing I am interested in, but haven’t found a good solution to, is how to have my entity base class define a byte[] Timestamp column to use for concurrency with a SQL Server database’s Timestamp datatype.

    Ideally, I want a convention to map that property in each Entity to a Version element that would like this:

    generated="always"
    unsaved-value="null"
    type="BinaryBlob">

    not-null="false"
    sql-type="timestamp"/>

    The not-null=”false” is required for testing against SQLITE. I’ve tried to use the IVersionConvention but can’t get the mapping to look like I want.

    Automatic concurrency is an important topic to many and I think if you can get this working and show how to do it, your readers would be very interested.

    Thanks,
    Corey