Skip to content

User type conventions

chester89 edited this page Feb 6, 2013 · 1 revision

Using conventions for user defined types

There are times when you have a complex type - let's say, Instant from NodaTime library - and you don't exactly know how to store it in your database. There are at least two ways of handling this situation - define a component for this type or implement a IUserType. At the time of this writing, Component mapping has a downside - it's not currently compatible with automapping.

Integrating IUserType into your existing mapping infrastructure

Getting to persist your magic type in the database using IUserType is easy - all you need to do is:

  • implement IUserType interface which is part of NHibernate core library
  • implement corresponding UserTypeConvention to let Fluent know how exactly do you want it mapped