I have moved my active blog over to tumblr. I've maintained this blog for reference but will be posting to http://www.robustsoftware.co.uk instead. I've pointed my Feedburner feed to tumblr so if you're subscribed already you should already have switched with me.

Mapping a GUID to a string with NHibernate

In a project I’m working on at the moment I needed to back a GUID to a string as it didn’t seem to be working out of the box with my SQLite database. It was saving it to whatever type of column I gave it in what looked like byte form leading to some crazy characters. However, it was falling over when trying to hydrate the field from that column.

Now I’m probably epic failing and there’s a much easier way to do this but I ended up creating a custom user type for doing this which I've made available on gist. I won’t be surprised if there’s an easier way and please let me know about it with a comment. I’ve also included the Fluent NHibernate class map to show how it use it if you’re not familiar with custom user types.

This got me moving again and googling how to do this came up blank, hence the blog post.