Hey Luka,
This is how I do enum as strings for all enum in my model when using
convention mapper:
// Save enums as strings in DBmapper.AfterMapProperty +=
(modelInspector, member, propertyCustomizer) =>
{
var propertyType = member.LocalMember.GetPropertyOrFieldType();
if (propertyType.IsEnum == false) return;
var nhEnumType =
typeof(EnumStringType<>).MakeGenericType(new[] { propertyType });
var typeInstance = Activator.CreateInstance(nhEnumType) as IType;
propertyCustomizer.Type(typeInstance);
};
Note that "GetPropertyOrFieldType()" is extension method in NH mapping by
code.
Fabio,
Please review and feel free to point to a better away. You created this
stuff (thanks really) and know them best for sure.
Regards,
*Mohamed Meligy
*Readify | Senior Developer
M:+61 451 835006 | W: readify.net
[image: Description: Description: Description: Description:
rss_16]<http://gurustop.net>
[image: Description: Description: Description: Description:
cid:[email protected]]
<http://www.linkedin.com/in/meligy> [image:
Description: Description: Description: Description:
cid:[email protected]] <http://twitter.com/meligy>
<http://www.greatplacetowork.com.au/best/best-companies-australia.php><http://www.readify.net/AboutUs/NewsItem.aspx?id=10>
On Tue, May 24, 2011 at 5:39 PM, Luka <[email protected]> wrote:
> thanks Fabio
>
> On May 23, 2:22 pm, Fabio Maulo <[email protected]> wrote:
> > Is not a matter of mapping.
> > It is a matter for the persistent type; in your case instead of
> EnumStringType>T>
> > you have to use your implementation.
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" 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/nhusers?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.