表达式“ dest => dest.Request.ID”必须解析为顶级成员,而不是任何子对象的属性

时间:2019-01-25 16:34:12

标签: automapper automapper-3 automapper-2 automapper-5 automapper-4

我想知道为什么会出现此错误,以及如何解决此错误而不为单个类创建单独的映射。

我有两个要自动映射的类。 对于其他两个类,我也采用了相同的方法,并且可以完美地映射它,但是对于这些类,它并没有被映射并抛出错误。

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));

0 个答案:

没有答案