I’m looking into a project using nhibernate and I have a question on how to best accomplish the following scenario, using FluentNhibernate 1.0.0.593, and NHibernate 2.1.0.4000
My tables look like this:
DeviationLog:
Id uniqueidentifier
DeviationType uniqueidentifier
IncomingMessageId uniqueidentifier
DeviationType:
Id uniqueidentifier
DeviationTypeCategory uniqueidentifier
DeviationMessage nvarchar(255)
DeviationTypeCategory:
Id uniqueidentifier
DeviationTypeCategoryName nvarchar(255)
I am currently making use of automapping with conventions.
When I create an instance of Deviation, I would like to be able to do something like the following:
var deviation = new Deviation{DeviationType=DeviationEnum.NoMatchMobileNumber};
Now as far as I know enums only support integral types, so this won’t work without an alternative approach. I was thinking of maybe using a dictionary to this, like Dictionary<DeviationEnum,Guid>, and I also suspect I might need to make use of UserTypeConvention<T> to make this work somehow.
Anyone got experiences to share?
What I’ve traditionally done is use a custom IUserType class that would translate between the enum in question and how it would be persisted. However, this required a custom IUserType per enum type.