在我的方法中,我得到了包含几个字符串列表和复杂类型对象列表的结果。
var AcctLst = gd.validateGroupMembershipUploadDetails(_input);
Mapper.CreateMap<Data.Entities.Upload.GroupMembershipValidationOutput, Business.Upload.GroupMembershipValidationOutput>();
var result = Mapper.Map<Data.Entities.Upload.GroupMembershipValidationOutput, Business.Upload.GroupMembershipValidationOutput>(AcctLst);
return result;
var AcctLst包含样本数据:
Data.Entities.Upload.GroupMembershipValidationOutput
和
Business.Upload.GroupMembershipValidationOutput
看起来像
public class GroupMembershipValidationOutput
{
public List<string> _validMasterIds { get; set; }
public List<ChapterCodeValidationOutput> _validChapterCodes { get; set; }
public List<GroupCodeValidationOutput> _validGroupCodes { get; set; }
public List<string> _invalidMasterIds { get; set; }
public List<string> _invalidChapterCodes { get; set; }
public List<string> _invalidGroupCodes { get; set; }
}
public class ChapterCodeValidationOutput
{
public string chpt_cd { get; set; }
public string appl_src_cd { get; set; }
}
public class GroupCodeValidationOutput
{
public string grp_cd { get; set; }
public string grp_nm { get; set; }
}
我猜_validChapterCodes和_validGroupCodes抛出以下异常:
Missing type map configuration or unsupported mapping.
Mapping types:
ChapterCodeValidationOutput -> ChapterCodeValidationOutput
ARC.Donor.Data.Entities.Upload.ChapterCodeValidationOutput -> ARC.Donor.Business.Upload.ChapterCodeValidationOutput
Destination path:
GroupMembershipValidationOutput._validChapterCodes._validChapterCodes._validChapterCodes0[0]
Source value:
ARC.Donor.Data.Entities.Upload.ChapterCodeValidationOutput
答案 0 :(得分:2)
var AcctLst = gd.validateGroupMembershipUploadDetails(_input);
Mapper.CreateMap<Data.Entities.Upload.ChapterCodeValidationOutput, Business.Upload.ChapterCodeValidationOutput>();
Mapper.CreateMap<Data.Entities.Upload.GroupCodeValidationOutput, Business.Upload.GroupCodeValidationOutput>();
Mapper.CreateMap<Data.Entities.Upload.GroupMembershipValidationOutput, Business.Upload.GroupMembershipValidationOutput>();
var result = Mapper.Map<Data.Entities.Upload.GroupMembershipValidationOutput, Business.Upload.GroupMembershipValidationOutput>(AcctLst);
return result;
然后它完美无缺。