1

I want to know why we will get this error and how to resolve it without creating seperating mapping for individual classes.

I have two classes which I want to automap. I have followed the same approach for other two classes and it is being mapped perfectly but for these classes, It isn't being mapped and throwing the error.

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));
Teja Swaroop
  • 185
  • 1
  • 12
  • Maybe you use an older version. Because the message continues with "You can use ForPath, a custom resolver on the child type or the AfterMap option instead.". – Lucian Bargaoanu Jan 25 '19 at 16:38
  • Thank You for the answer. I forgot that I was using ForPath for the other mapping and assuming something else is happening. Assumption is Mother of all F-Ups. – Teja Swaroop Jan 25 '19 at 16:52

0 Answers0