Hi James
Thats my fault when I first wrote the automapper I didn't know that
nhibernate could map enums so i turned it off as I had a bunch of enums in
my code i didnt want mapped. Seems my inexperience with nhibernate in
regards to enums, forced me into that mistake.

Sorry guys.

Andy

On Wed, Feb 18, 2009 at 1:23 PM, James Gregory <[email protected]>wrote:

> 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 <[email protected]>wrote:
>
>>
>> James
>>
>> Have you had any ideas on this one yet?
>>
>> Mark
>>
>> On Feb 13, 3:07 pm, Mark Perry <[email protected]> wrote:
>> > James
>> >
>> > Is there anything I can do to help you out further?
>> >
>> > Mark
>> >
>> > On Feb 12, 5:51 pm, James Gregory <[email protected]> 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 <
>> [email protected]>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 <[email protected]> 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 <[email protected]>
>> 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 <[email protected]>
>> 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 <
>> > > > [email protected]>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
>>
>>
>
> >
>


-- 
=================
I-nnovate Software - Bespoke Software Development, uk wirral.
http://www.i-nnovate.net

Easy Project Managment Online
http://www.task-mate.com

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

Reply via email to