这种性质的一个有趣的问题。我正在尝试将列表映射到列表。即比较两个同质对象。 但是,映射器向我抛出异常
缺少类型映射配置或不受支持的映射。
如果有任何帮助,我将不胜感激!我一整天都解决不了问题。
CreateMap<List<GrammarQuestionDTO>, TestDTO>()
.ForMember(t => t.GrammarQuestion, map => map.MapFrom(source => source))
.ForAllOtherMembers(x => x.Ignore());
public class GrammarQuestionDTO
{
public int Id { get; set; }
public LevelType LevelType { get; set; }
public QuestionType QuestionType { get; set; } = QuestionType.Grammar;
public string Question { get; set; }
public List<AnswerDTO> Answers { get; set; }
}
public class TestDTO
{
public int Id { get; set; }
public List<GrammarQuestionDTO> GrammarQuestion { get; set; }
public List<AuditionQuestionDTO> AuditionQuestion { get; set; }
public string EssayTopic { get; set; }
public string SpeakingTopic { get; set; }
}