OK adding this make everything work as I want, but enums still aren't
mapped by default. Seems to be because enums dont end up as IProperty
(as per EnumerationPropertyConvention) but are in fact an IUserType

Andrew

        public class EnumMappingConvention : IUserTypeConvention
        {
                public bool Accept(IProperty target)
                {
                        return target.PropertyType.IsEnum;
                }

                public void Apply(IProperty target)
                {
                        target.CustomTypeIs(target.PropertyType);
                }

                public bool Accept(Type type)
                {
                        return type.IsEnum;
                }
        }


On Mar 18, 12:35 pm, "trull...@googlemail.com"
<trull...@googlemail.com> wrote:
> In a recent previous version of FNH i hacked FNH/Mapping/
> EnumerationTypeConvention, replacling this line:
>
> Type mapperType = typeof(GenericEnumMapper<>).MakeGenericType
> (propertyMapping.PropertyType);
>
> with this:
>
> Type mapperType = propertyMapping.PropertyType;
>
> to make my enums be saved as Ints in the db.
>
> I've just updated to the latest FNH and now my enums aren't being
> mapped at all (not even as a string, as id expect by the default
> behaviour)
>
> i get: "could not resolve property: XXX of: YYY" at runtime, where
> property XXX is an enum : int, and YYY is my class, which after
> debugging makes sense because all Enum properties on any object aren't
> being mapped.
>
> It appears that TryToMapProperty in AutoMapper can't/doesn't map my
> enum types.
>
> I assume the automapcolumn rule should be the one to map the enum
> columns, the MapsProperty method in there first returns false for
> "HasExplicitTypeConvention" then because its not in the system
> namespace, returns false and therefore isnt mapped.
>
> I can see that registering an explicit type convention could make this
> work, but:
>
> a) i shouldnt have to do that for every enum type
> b) why doesnt FNH do it automatically, it used it!
>
> Thanks
>
> Andrew
--~--~---------~--~----~------------~-------~--~----~
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