Given the following sources:
public class SourceBase { public string TheString { get; set; } } public class SourceDerived : SourceBase { }
and destinations:
public class DestBase { public string MyString { get; set; } } public class DestDerived : DestBase { }
And this mapping:
CreateMap<SourceBase, DestBase>() .ForMember(dest => dest.MyString, o => o.MapFrom(x => x.TheString)) .Include<SourceDerived, DestDerived>(); CreateMap<SourceDerived, DestDerived>(); Mapper.AssertConfigurationIsValid();
However, this gives a display error in which MyString is not displayed in DestDerived. What gives? Do I really need to repeat the mappings for the properties of the base class in all derived types (I have several subclasses in my actual code).
EDIT:
Exact exception. The following 1 properties in DestDerived cannot be mapped: MyString. Add your own display expression, ignore or rename the property to DestDerived.
source share