我想使用自动映射器自动映射两个模型。
具有属性的模型A
public string field1 {get; set;}
public string field2 {get; set;}
具有属性的模型B
public string field1 {get; set;}
public string field2 {get; set;}
public string field3 {get; set;}
AND
CreateMap<ModelA, ModelB>()
.ForMember (d => d.field1, o => o.MapFrom (s => s.field1))
.ForMember (d => d.field2, o => o.MapFrom (s => s.field2))
.ForAllOtherMembers (opts => opts.Ignore ());
但是我得到这个错误:
未映射的属性:field3
FrontEnd Controller调用:
ModelB oModelB = mapper.Map<ModelA,ModelB>(pModelA);