我在项目级别有两个类,我想用 Auto Mapper 映射它们,但出现映射错误,你能帮助我吗?
public class RegisterVm
{
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Mobile { get; set; }
[Required]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
}
public class RegistrationRequest
{
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Mobile { get; set; }
[Required]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
}
收到错误
我使用以下代码进行映射,但出现错误
CreateMap<RegisterVm, RegistrationRequest>().ReverseMap();
删除ReverseMap()并编写类似以下的代码:
创建地图