Search code examples
.netsql-server-2005nhibernateormuint32

How to map uint in NHibernate with SQL Server 2005


I have a property of type uint on my entity. Something like:

public class Enity
{
   public uint Count {get;set;}
}

When I try to persist that into the SQL Server 2005 database, I get an exception

Dialect does not support DbType.UInt32

What would be the easiest way to workaround this. I could for example store it as long in the DB. I only don't know how to tell that to NHibernate.


Solution

  • The cleanest, most official solution would probably be to write a user type.

    Take an example, like this one and adapt it. If you have many uint's, it is worth to have a user type.

    <property name="Prop" type="UIntUserType"/>