Automapper DynamicMap missing

时光毁灭记忆、已成空白 提交于 2019-12-13 02:49:00

问题


I was reading in a previous question on "How to use AutoMapper to map a DataRow to an object in a WCF service?" and I thought 'Great! That's what I'm looking for on mapping a table from MySQL!', yet after I got the Nuget package and tried to use that line of code like this:

List<Customer> c = AutoMapper.Mapper.DynamicMap<IDataReader, List<Customer>>(dt.CreateDataReader());

I got this exception:

'Mapper' does not contain a definition for 'DynamicMap'

After checking around on the 'net about it, I found out it's been taken out. So then how does one create a List from MySQL DB Table?


回答1:


DataReaderMapper can be used to achieve this. See https://github.com/aygjiay/AutoMapper.DataReaderMapper or https://github.com/AutoMapper/AutoMapper.Data for details.




回答2:


The AutoMapper has many changes since the 3.1.1 version.

The below change from DynamicMap method to Map method should work.

List<Customer> c = AutoMapper.Mapper.Map<IDataReader, List<Customer>>(dt.CreateDataReader());


来源:https://stackoverflow.com/questions/45007054/automapper-dynamicmap-missing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!