具有IDataReader to List的AutoMapper始终返回0计数

时间:2015-10-23 11:16:16

标签: c# asp.net-mvc automapper automapper-4

我在我的应用程序中使用了最新版本的AutoMapper。 我想将DataTable对象转换为List类型, 我正在使用以下代码 读者的类型为DataTable

Mapper.CreateMap<IDataReader, List<AutoShiftReportConfigDto>>();
var response = Mapper.Map<IDataReader, List<AutoShiftReportConfigDto>>(reader.CreateDataReader());

但它总是返回0计数, 我的DataTable列名称与AutoShiftReportConfigDto的属性类型和名称

相同

1 个答案:

答案 0 :(得分:3)

自版本4起,AutoMapper对IDataReader的处理已从core中撤出。它最终会落在Automapper.Data。如果您需要这个,请坚持使用版本3.x。

Source