My domain model is using System.Net.Uri to represent URLs, and System.Drawing.Color to represent colors. In the db, uris are simply nvarchars and colours are web (hex) rgb values.
Using NHibernate, is there some way to map between these values using some custom mapper?
I don’t need to query against these items, but it would be nice if I could.
Any help is greatly appreciated.
What you need are user types. Implement
IUserTypeorIComplexUserType(there are some more interfaces to match other needs).There are some examples:
Using the user type, you can map any class to any number of columns of any type. Implementing the user type means implementing the mapping between them.
The mapping could look like this: