Multi level Library

Fix could not determine type exception in N-Hibernate

nHibernate is something I used for 1 project over 5 years ago when I wanted to pull geospatial data from a PostgreSql database. It was straight forward to use and wasn’t as bound to a database as Entity Framework (EF) was at the time, and its performance was great.

Since then I have been using EF for Object Relational Mapping (ORM) tasks and have largely forgotten how to use nHibernate.

Recently I have moved to a outfit that use nHibernate, so I decided to refresh my understanding by adding nhibernate into a project I am working on at home.

I had a repository class that I had quickly set up using SQLCommand to query a test database, which I replaced with NHibernate mapping. The simple classes, where I queried one table worked fine and were easy to setup, however when I tried to set up a more complex example with 2 tables linked by a foreign key and a many-to-one relationship I came across an error in my unit testing.

Continue reading →