Unit of Work & Repository support for multiple frameworks, part 2

By | March 13, 2011

Quite a while ago I made a post about creating a unit of work and a repository that would allow me to swap between Entity Framework and NHibernate relatively quickly. In the past few weeks (or have they turned into months already?!), I received a few requests for a sample project to show how this can be implemented and used in a real world scenario. I sat down to work on it this weekend and I’m happy to say I managed to finish a working sample project.

Click here to download the sample project.

Keep in mind that I won’t take responsibility for any of this code if you decide to deploy it in a production environment. However, feel free to use this code for your own projects and modify it to suit your own needs. It’s only meant to provide a sample and show a way how to implement repositories that are not dependant on a specific type of framework.

I truly hope my efforts are appreciated and that it can be a learning experience for everyone who requested a sample project on this issue!

Read more »

Happy birthday!

By | March 9, 2011

Especially for my honey buns! I can’t believe it’s been another year already, here’s a happy birthday dance from your favourite pet animal:

:D

Do not blindly trust online journey planners!

By | March 8, 2011

When I use the public transport to go to a location that I’ve never visited before, I always use the online journey planners to help me guide along the way. Today, by pure accident, I found that the journey planner from the NS (Nederlandse Spoorwegen) does not always give the quickest route to the given destination. Here’s a little example I stumbled on:

Assume that I’d wanted to travel from Geldrop to Roermond. Easy enough, I’ll just check the journey planner to see how long it will take me. By default, the planner gives me the following advice:

I was a little surprised at the journey time. I had expected the travel time to be a lot shorter. Taking a closer look, I noticed that the journey planner wants to send me to Weert and let me stand around in the cold for 20 minutes to change to the Intercity service to Roermond. Just out of curiosity I decided to look up the same route but via Eindhoven, because I know that changing trains there means a lot less waiting time. To my (delighted) surprise I saw the following:

The total time is 10 minutes less then the previous advice! I suppose there could be a few explanations for this behaviour; the first example is cheaper and it’s the most direct route towards the destination. For me personally, a cheaper route doesn’t matter as I have a year subscription that allows me to travel on any train to any destination! So, my little tip of the day is to never blindly trust on the advice of the journey planner!

Think of all the things that can be done in the 10 minutes that I’ve just saved! Woohoo!

NHibernate: Association references unmapped class

By | March 7, 2011

If this exception message pops up when using NHibernate, make sure to check the following:

  • The mapping file is set as embedded resource;
  • The name of the mapping file ends with .hbm.xml instead of .xml;

I just spent two days wondering why this message kept occurring. Turns out that I had named my mapping file: SomeMapping.xml, instead of SomeMapping.hbm.xml.

Wouldn’t it be nice to have compile time checks on NHibernate mappings?! Wait… there is! It’s called Fluent NHibernate and we don’t use it here at work. ARGH! Perhaps I should see if I can spend a little time investigating how much effort it is to rewrite all the mappings using Fluent…

Random picture time!

By | March 4, 2011

Admiring the sunset while waiting for the next train to take me home!