public static void Main()
Mapper.AssertConfigurationIsValid();
var card = new CreateCardVm()
Audit = new AuditVm(){ TransId = 1, UserId = "A22", Shift = 3 },
var cmd = Mapper.Map<CreateCardVm, SetNewCardSettings>(card);
Mapper.CreateMap<AuditVm, CardBase>();
Mapper.CreateMap<AuditVm, SetNewCardSettings>()
SetNewCardSettings settings = new SetNewCardSettings();
Mapper.Map<AuditVm, CardBase>(src, settings);
.IgnoreUnmappedProperties();
Mapper.CreateMap<CreateCardVm, SetNewCardSettings>()
.ConstructUsing(src => Mapper.Map<SetNewCardSettings>(src.Audit))
.IgnoreUnmappedProperties();
public static class AutoMapperExtensions
public static IMappingExpression<TSource, TDestination> IgnoreUnmappedProperties<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
var typeMap = Mapper.FindTypeMapFor<TSource, TDestination>();
foreach (var unmappedPropertyName in typeMap.GetUnmappedPropertyNames())
expression.ForMember(unmappedPropertyName, opt => opt.Ignore());
public class CreateCardVm : CardVm
public AuditVm Audit { get; set; }
public int TransId {get; set; }
public string UserId { get; set; }
public int Shift { get; set; }
public string To { get; set; }
public string From { get; set; }
public string Subject { get; set; }
public int TransId {get; set; }
public string UserId { get; set; }
public int Shift { get; set; }
public class SetNewCardSettings : CardBase
public string To { get; set; }
public string From { get; set; }