Missing type map configuration or unsupported mapping

萝らか妹 提交于 2019-12-08 07:16:28

This basically means AutoMapper is missing information about how to map from one property to another.

Though I can't tell by looking at the error, you can try the following process to figure out which property is missing the mapping. Start out by ignoring all of your destination type's properties:

Mapper.CreateMap<Question, QuestionDto>()
    .ForMember(d => d.ID, o => o.Ignore())
    .ForMember(d => d.next, o => o.Ignore())
    .ForMember(d => d.question, o => o.Ignore())
    .ForMember(d => d.QuestionPhrase, o => o.Ignore())
    .ForMember(d => d.Next, o => o.Ignore())
    .ForMember(d => d.QuestionAnswer, o => o.Ignore())
    .ForMember(d => d.UserAnswer, o => o.Ignore())
    // also ignore any other properties
;

Then, one by one, uncomment the ForMember lines until your exception is raised again. That is the property AM can't figure out how to map. I suspect is is in one of your collection properties...

Update

I'm wondering if perhaps there is a recursion problem going on here. Try this:

.ForMember(d => d.Next, o => o.ResolveUsing(s => {
    var tryToMap = Mapper.Map<QuestionDto>(s.Next); // exception here???
    return null;
}));

Not saying you have a data problem here, but if you did, you should expect AM to throw. If your question.Next == question, I imagine that AM would overflow the stack trying to map a property to it's owner over and over again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!