Here\'s a simplified example of what I\'m trying to do... let\'s say I have an the followin
Question 1: Not that I am aware of.
Question 2: When using the .ConstructUsing()
make sure you return the mapped object you are after rather than a fresh instance.
e.g.
Mapper.Initialize(config =>
{
config.CreateMap<IPerson, PersonDto>()
.Include<IModelPerson, ModelPersonDto>()
.ConstructUsing((IPerson person) =>
{
if (person is IModelPerson) return Mapper.Map<ModelPersonDto>(person);
throw new InvalidOperationException("Unknown person type: " + person.GetType().FullName);
})
;
config.CreateMap<IModelPerson, ModelPersonDto>();
});