So, I can just use something like:

Map( x=> x.MyEnumProperty);

Or use the

Map(x => x.MyEnumProperty).CustomType(typeof(EnumStringType));

Or something else ?


Thank you.

Regards,

--
Mohamed Meligy
Senior Developer, Team Lead Backup (.Net Technologies) – Applications
Delivery - TDG
Injazat Data Systems
P.O. Box: 8230 Abu Dhabi, UAE.

Phone:  +971 2 6992700
Direct:   +971 2 4045385
Mobile:  +971 50 2623624, +971 55 2017 621

E-mail: eng.mel...@gmail.com
Weblog: http://weblogs.asp.net/meligy


On Mon, Nov 9, 2009 at 3:50 AM, Chris C <chilve...@googlemail.com> wrote:

>
> NHibernate already provides a custom type for that, EnumStringType.
> Check out the classes in NHibernate.Types.
>
> On Nov 8, 9:46 pm, Mohamed Meligy <eng.mel...@gmail.com> wrote:
> > Hey,
> >
> > May this reach the wiki or so? I think it's very important.
> >
> > I also have another question: What if it was a string column instead of
> > int?, where the value of the column is myEnumValue.ToString() ad the
> value
> > of the enum comes from  (EnumType) Enum.Parse( typeof(EnumType),
> > ColumnValue)... how would that be mapped ?
> >
> > Regards,
> >
> > --
> > Mohamed Meligy
> > Senior Developer, Team Lead Backup (.Net Technologies) – Applications
> > Delivery - TDG
> > Injazat Data Systems
> > P.O. Box: 8230 Abu Dhabi, UAE.
> >
> > Phone:  +971 2 6992700
> > Direct:   +971 2 4045385
> > Mobile:  +971 50 2623624, +971 55 2017 621
> >
> > E-mail: eng.mel...@gmail.com
> > Weblog:http://weblogs.asp.net/meligy
> >
> >
> >
> > On Sat, Nov 7, 2009 at 8:11 PM, Chris C <chilve...@googlemail.com>
> wrote:
> >
> > > You're problem is in the mapping file. A convention won't overwrite a
> > > mapping if there is one, this makes it easy in a convention to set
> > > defaults if a value hasn't been provided by the mapping but without
> > > having to ensure you're not overwriting an existing mapping.
> >
> > > In you're mapping itself you're telling it the custom type for your
> > > property is your "EnumConvention" hence the convention won't be able
> > > to change that. Secondly, conventions are automatically run against
> > > all the mappings in the project so you don't have to tell it to apply
> > > the convention.
> >
> > > So in you're mapping it should just read:
> > >  Map(x => x.QueueType, "queueTypeID"); //Custom convention will set
> > > the CustomType
> >
> > > Or,
> > >   Map(x => x.QueueType, "queueTypeID").CustomType(typeof
> > > (QueueTypeEnum)); //Set explicitly, convention won't change this
> >
> > > On Nov 5, 6:16 pm, cconway <cconwa...@gmail.com> wrote:
> > > > Hello,
> > > > I'm having some issues trying to map an enum property using it's
> > > > integer value as opposed to the string value. Her's what I've got and
> > > > hopefully someone can tell me what I'm doing wrong. I'm using 1.0RTM
> > > > by the way.
> >
> > > > First, I've got a class call EnumConvention that looks like this:
> > > > public class EnumConvention : IUserTypeConvention
> > > > {
> > > >         public void Accept(IAcceptanceCriteria<IPropertyInspector>
> > > criteria)
> > > >         {
> > > >                 criteria.Expect(x => x.Property.PropertyType.IsEnum);
> > > >         }
> > > >         public void Apply(IPropertyInstance instance)
> > > >         {
> > > >                 instance.CustomType(instance.Property.PropertyType);
> > > >         }
> >
> > > > }
> >
> > > > In my mapping file, I've got the following:
> > > > Map(x => x.QueueType, "queueTypeID").CustomType(typeof
> > > > (EnumConvention));
> >
> > > > The hbm that is generated looks like this:
> > > > <property name="QueueType" type="RMS.Data.Conventions.EnumConvention,
> > > > RMS.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
> > > >       <column name="queueTypeID" />
> > > >     </property>
> >
> > > > NHibernate.MappingException: Could not determine type for:
> > > > TotalVisibility.RMS.Data.Helpers.EnumConvention,
> > > > TotalVisibility.RMS.Data, Version=1.0.0.0, Culture=neutral,
> > > > PublicKeyToken=null, for columns: NHibernate.Mapping.Column
> > > > (queueTypeID)
> >
> > > > Am I missing something? I thought I followed all the steps.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to