我想知道为什么会出现此错误,以及如何解决此错误而不为单个类创建单独的映射。
我有两个要自动映射的类。 对于其他两个类,我也采用了相同的方法,并且可以完美地映射它,但是对于这些类,它并没有被映射并抛出错误。
public class DecisionRequestResponse
{
public string ReqId { get; set; }
public string Decision { get; set; }
public string ReasonId { get; set; }
public string NotUsedInDecision { get; set; }
public string SrcEQ { get; set; }
public string SrcTU { get; set; }
public string SrcBancoInternal { get; set; }
public string SrcExternal { get; set; }
public string ReasonCodeId { get; set; }
}
public class DecisionRequestResponseObj
{
public REQUEST Request { get; set; }
public REQUESTEXT RequestExt { get; set; }
public REQDECISIONREASON ReqDecisionReason { get; set; }
}
CreateMap<DecisionRequestResponse, DecisionRequestResponseObj>()
.ForMember(dest => dest.Request.ID, opt => opt.MapFrom(src => src.ReqId))
.ForMember(dest => dest.Request.PROPOSEDAMTTOTAL, opt => opt.MapFrom(src => src.EvaluatedAmt))
.ForMember(dest => dest.RequestExt.ID, opt => opt.MapFrom(src => src.ReqId))
.ForMember(dest => dest.RequestExt.TEMPDECISIONSTATUSCD, opt => opt.MapFrom(src => src.Decision))
.ForMember(dest => dest.ReqDecisionReason.ID, opt => opt.MapFrom(src => src.ReasonId))
.ForMember(dest => dest.ReqDecisionReason.REQID, opt => opt.MapFrom(src => src.ReqId))
.ForMember(dest => dest.ReqDecisionReason.NOTUSEDINDECFLG, opt => opt.MapFrom(src => src.NotUsedInDecision));