Well, that line you highlighted in AutoMapper doesn't make any sense.
Removing it allows the automapper to map Enums; however, the recommended
behavior in NHibernate is to map enums as strings, and that's what the
automapper does.
If you really must use enums as ints, then you'll need to manually set the
type attribute on the property. I've updated the enum convention to ignore
any enum properties that already have their type set.

Map(x => x.MyEnum)
  .SetAttribute("type", "Int32");

On Wed, Feb 18, 2009 at 9:17 AM, Mark Perry <markperr...@googlemail.com>wrote:

>
> James
>
> Have you had any ideas on this one yet?
>
> Mark
>
> On Feb 13, 3:07 pm, Mark Perry <markperr...@googlemail.com> wrote:
> > James
> >
> > Is there anything I can do to help you out further?
> >
> > Mark
> >
> > On Feb 12, 5:51 pm, James Gregory <jagregory....@gmail.com> wrote:
> >
> > > I'm not sure why those checks are in there, but I'll investigate when I
> next
> > > get an opportunity.
> >
> > > On Thu, Feb 12, 2009 at 4:01 PM, Mark Perry <
> markperr...@googlemail.com>wrote:
> >
> > > > Here as well in AutoMapComponent.cs
> >
> > > > Line 35
> >
> > > > if (property.PropertyType.IsEnum || property.GetIndexParameters
> > > > ().Length != 0) continue;
> >
> > > > After taking both of the checks for "property.PropertyType.IsEnum"
> > > > from the source code and
> > > > running the auto mapper I get the XML outputting correctly.
> >
> > > > <property name="DisplayAs" column="DisplayAs"
> > > > type="FluentNHibernate.Mapping.GenericEnumMapper`1
> > > > [[Engineering.Domain.DisplayAs, Engineering.Domain, Version=1.0.0.0,
> > > > Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
> > > > Version=0.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880">
> > > > <column name="DisplayAs" sql-type="string" />
> > > > </property>
> >
> > > > I guess internally it's using the EnumerationTypeConvention() to do
> > > > the business. Unfortunately I cannot get the automapper to break into
> > > > my ITypeConvention for my Enum.
> >
> > > > Also the default is to store as a string in the DB and not an Int
> > > > which it what I would like.
> >
> > > > Dunno if any of this helps at all.
> >
> > > > Thanks, Mark
> >
> > > > On Feb 12, 3:19 pm, Mark Perry <markperr...@googlemail.com> wrote:
> > > > > Seems like the AutoMapper will always ignore Enums from the
> generated
> > > > > maps:
> >
> > > > > AutoMapper.cs line 57
> >
> > > > > if (!property.PropertyType.IsEnum && property.GetIndexParameters
> > > > > ().Length == 0)
> >
> > > > > Am I right here or should I be doing something else?
> >
> > > > > Mark
> >
> > > > > On Feb 12, 3:02 pm, Mark Perry <markperr...@googlemail.com> wrote:
> >
> > > > > > @Steve
> >
> > > > > > Yeah I get the state thing but all I want is a simple Enum to DB
> int
> > > > > > mechanism.
> > > > > > From my previous post I don't think this is currently working in
> the
> > > > > > AutoMapper.
> >
> > > > > > Thanks, Mark
> >
> > > > > > On Feb 12, 2:50 pm, Steven Harman <stevehar...@gmail.com> wrote:
> >
> > > > > > > Mark,
> > > > > > > I like Derick Bailey's approach to solving this - Mapping a
> State
> > > > Pattern
> > > > > > > with NHibernate:
> > > >
> http://www.lostechies.com/blogs/derickbailey/archive/2008/11/26/mappi...
> >
> > > > > > > -steve
> >
> > > > > > > //----  90% of being smart is knowing what you're dumb at
>  ----//
> > > >http://stevenharman.net/
> >
> > > > > > > On Thu, Feb 12, 2009 at 9:12 AM, Mark Perry <
> > > > markperr...@googlemail.com>wrote:
> >
> > > > > > > > Hi
> >
> > > > > > > > Sorry to keep pestering the list like this I feel like I'm
> being a
> > > > > > > > right pain in the [insert word here].
> >
> > > > > > > > I wanted to have to AutoMapper map one of my properties which
> is an
> > > > > > > > Enum but it seems as
> > > > > > > > if the AutoMapper just ignores it.
> >
> > > > > > > > I know there is an example on the wiki
> > > > > > > >
> http://wiki.fluentnhibernate.org/show/AutoMappingTypeConventions
> > > > > > > > but I just want to store my enum as an Int in the Db and have
> it as
> > > > an
> > > > > > > > enum in my object and not go to the
> > > > > > > > length of implementing IUserType.
> >
> > > > > > > > I think I need to add an ITypeConvention to handle my
> EnumType and
> > > > add
> > > > > > > > a custom attribute to describe
> > > > > > > > the type of my enum?
> >
> > > > > > > > Am I along the right lines here?
> >
> > > > > > > > Thanks, Mark
> >
>

--~--~---------~--~----~------------~-------~--~----~
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