我无法让下面的代码正常运行,其中array是一个CustomerContract数组:
在我的想法中,第一个示例应该足够了,但我无法使它们都起作用。我已经阅读了Automapper的配置wiki(https://github.com/AutoMapper/AutoMapper/wiki/Configuration),但我不明白为什么这是必要的。 Automapper需要的一切都在命令中定义。它是哪种类型(对象和列表),以及我想将其映射到哪个对象。
Mapper.Map<IEnumerable<Customer>>(array);
Mapper.Map<IEnumerable<CustomerContract>, IEnumerable<Customer>>(array);
Mapper.Map<Array, List<Customer>>(array);
在我的想法中,第一个示例应该足够了,但我无法使它们都起作用。我已经阅读了Automapper的配置wiki(https://github.com/AutoMapper/AutoMapper/wiki/Configuration),但我不明白为什么这是必要的。 Automapper需要的一切都在命令中定义。它是哪种类型(对象和列表),以及我想将其映射到哪个对象。
我是否没有理解Automapper的核心概念?
我的异常信息如下:
缺少类型映射配置或不支持映射。
映射类型:\r\nCustomerContract -> Customer\r\nStimline.Xplorer.Repository.CustomerService.CustomerContract -> Stimline.Xplorer.BusinessObjects.Customer
目标路径:List`1[0]
源值:Stimline.Xplorer.Repository.CustomerService.CustomerContract