Today was my first real day playing with NHibernate.
The documentation is a little much for a beginner such as myself, but I managed to struggle through it… especially with the help of my coworkers.
For those of you who don’t know, NHibernate is an Object/Relation Mapper (ORM). It classically uses XML files as meta-data to help with its job. I personally did not like the idea of having embedded XML resources in my project, so I was very pleased when I found the NHibernate.Mapping.Attributes package that allows me to use native C# attribute tagging instead of embedded XML.
One thing that was not entirely obvious to me was that, despite NHibernate 1.0.2 being a .NET 1.1 resource, it does support nullable types (which were first introduced in .NET 2.0). Say, for example, you have a DateTime in your database that is specified as a nullable field. In your container object you have a DateTime? (notice the question mark). To make NHibernate work with this you will have to do two things.
1) Specify in your NHibernate attributes the C# type (in this case only Specify System.DateTime, ignoring the nullable)
2) Specify in your NHibernate attributes that NotNull is equal to false (ie, it is nullable)
That’s it! That seems to be all I had to do to get NHibernate 1.0.2 to work with nullable types!