I have moved from specifying fluent configurations using ClassMaps to using
auto-mapping but I am having a problem with property conventions.
The problem is that the auto-mapper is mapping all class-based properties as
many-to-one references by default. This is great in most cases but I want
all properties derived from Enumeration to be mapped as properties instead
to take advantage of the following convention.
public class EnumerationTypeConvention : IPropertyConvention,
IPropertyConventionAcceptance
{
private static readonly Type OpenType = typeof(EnumerationType<>);
public void Apply(IPropertyInstance instance)
{
Type closedType =
OpenType.MakeGenericType(instance.Property.PropertyType);
instance.CustomType(closedType);
}
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
criteria.Expect(x =>
typeof(Enumeration).IsAssignableFrom(x.Property.PropertyType));
}
}
Currently I am having to override every Enumeration-derived property by hand
using an AutoMappingOverride class, which is not the end of the world, but
it would be great if there was a way to do this automatically.
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/fluent-nhibernate/-/yaCX9xCIPtYJ.
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.