AutoMapping overrides and inheritance

Dmitry Kryuchkov's Avatar

Dmitry Kryuchkov

24 Oct, 2010 03:58 PM via web

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?

  1. Support Staff 2 Posted by James Gregory on 05 Nov, 2010 02:05 PM

    James Gregory's Avatar

    This should be possible with conventions. Have a read of that and let us know if there's anything that's unclear.

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What is the opposite of bad?