我有两个班级:
public class AddFrequentQuestionModel
{
public string Question { get; set; }
public string Answer { get; set; }
}
public class FrequentQuestion : IEntity
{
public int Id { get; set; }
public string Question { get; set; }
public string Answer { get; set; }
}
想要将AddFrequentQuestionModel转换为FrequentQuestion
var frequentQuestion = _mapper.Map<FrequentQuestion>(model);
它向我显示以下错误:
找到未映射的成员。查看下面的类型和成员。添加一个 自定义映射表达式,忽略,添加自定义解析程序或修改 源/目标类型对于没有匹配的构造函数,添加一个无参数 ctor,添加可选参数,或映射所有构造函数参数
AddFrequentQuestionModel - &gt; FrequentQuestion(目的地成员列表) Calidda.ServiciosCliente.Application.FrequentQuestions.Commands.AddFrequentQuestions.AddFrequentQuestionModel - &GT; Calidda.ServiciosCliente.Domain.FrequentQuestions.FrequentQuestion(目的地成员列表)未映射的属性:Id
你能帮我吗?
PD:我的自动播放器按以下方式配置:
config.CreateMap< AddFrequentQuestionModel, FrequentQuestion >().ForMember(s=>s.Id,opt => opt.Ignore());