Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you map an enum as string in fluent nhibernate?

Is it possible to map an enum as a string using Fluent Nhibernate?

like image 551
Chris Conway Avatar asked Feb 02 '09 14:02

Chris Conway


2 Answers

Yes, it does that by default if you just do:

Map(x => x.YourProperty);

Make sure you're using the latest version off the trunk.


As Yavor Shahpasov pointed out in the comments, in more recent versions you can accomplish the same with:

Map(x => x.Property).CustomType<GenericEnumMapper<YourPropertyEnumType>>();
like image 82
Garry Shutler Avatar answered Oct 19 '22 02:10

Garry Shutler


and there is also the EnumString class you can pass as customType

like image 25
Jan Avatar answered Oct 19 '22 00:10

Jan