I have a database table that includes a two bit fields: IsEvenSide and IsOddSide. I want this to map to the following enum:
[Flags] enum SideOfStreet { None, Even, Odd }
I have done IUserType‘s in the past, but I don’t know how to map to multiple database fields.
How can this be done?
P.S.: I’m using Fluent NHibernate, but I’m okay with an hbm solution as well. I’ll just figure out how to convert it.
Map the database fields to read only properties in your class:
And control them through a public property:
[revised version to work with flag enumeration]
If you don’t want to expose getters for IsEvenSide and IsOddSide you can mark them private and use Reveal: