views:

1436

answers:

4

Edit: Ryan raised a good point. I specifically want to be able to map to and from while still storing human-readable values in the database. That is, I don't want a bunch of enumeration integers in my database.

A: 

I've never used NHibernate, but can't you just set the SQL datatype to int?

Ryan
Good point. I should have been more clear with my question. Fixed now.
Kevin Pang
+2  A: 

You have to implement a custom IUserType. See this post.

Max Stewart
+4  A: 

According to the documentation you can either leave the type attribute of the property in your mapping file blank or you define it and specify the class name of the enumeration.

Another way would be to convert the enumeration to an int and use the int as the mapped type.

Jasper
specifying the class name of the enumeration worked fine for me
Jason Barile
Link is broken.
Dan
A: 

I think you can just set the type to string:

<property name="EnumProperty" Type="string" Length="50" NotNull="true" />
David Kemp