AutoMapping overrides and inheritance
I suppose would be very useful if overrides functionality will use type hierarchy for processing. For example, I have entity named SomeEntity that implement interface IHasName with string property Name. By default, string property mappes to nullable NVARCHAR column (if you use MSSQL Server). If I want to override such behavior for all entities, that implement interface IHasName, I would like to write only one implementation of IAutoMappingOverride for interface IHasName, but at the moment it isn't possible.
public class SomeEntity : IHasName
{
public int Id { get; set; }
public string Name { get; set; }
}
public interface IHasName
{
string Name { get; set; }
}
public class HasNameOverride : IAutoMappingOverride<IHasName>
{
public void Override(AutoMapping<IHasName> mapping)
{
mapping.Map(x => x.Name)
.Not.Nullable();
}
}
Guys, what do you think about it?
Support Staff 2 Posted by James Gregory on 05 Nov, 2010 02:05 PM
This should be possible with conventions. Have a read of that and let us know if there's anything that's unclear.