automapper缺少类型映射配置或不支持的映射

时间:2013-01-30 13:44:43

标签: automapper

我正在尝试映射以下实体:

public class Person
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Address Address { get; set; }
    public DateTime DOB { get; set; }
    public List<Telephone> Telephones { get; set; }
}

public class SearchPersonViewModel
{
    public int Id { get; set; }
    public string FullName { get; set; }
    public string LicencePlate { get; set; }
    public string CarMake { get; set; }
    public string CarModel { get; set; }
}

我这样做:

  AutoMapper.Mapper.CreateMap<List<SearchPersonViewModel>, List<Person>>();
 List<SearchPersonViewModel> model = AutoMapper.Mapper.Map<List<Person>, List<SearchPersonViewModel>>(persons);

我得到异常'缺少类型映射配置或不支持的映射。'

我不知道我的代码有什么问题,任何人都可以提供帮助吗?

0 个答案:

没有答案