尝试映射 System.Collections.Generic.List 1 抛出异常
Trying to map System.Collections.Generic.List 1 Exception is thrown
我正在尝试映射 RecordDTO 和 Record。但是当我 运行 应用程序时,抛出异常。
RecordBL recordBL = new RecordBL();
List<Record> record = recordBL.GetAllRecords();
Mapper.CreateMap<RecordDTO, Record>();
List<RecordDTO> recordDTO = Mapper.Map<List<Record>,List<RecordDTO>>ecgrecord);
Mapper.AssertConfigurationIsValid();
return recordDTO;
异常是这样的:
Trying to map
System.Collections.Generic.List1[[Server.BusinessEntities.Record,
Server.BusinessEntities, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]] to
System.Collections.Generic.List1[[DTOs.RecordDTO,Server.DTOs,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
有人可以帮我解决这个问题吗?
你想映射从记录到记录DTO,所以你需要:
Mapper.CreateMap<Record, RecordDTO>();
我正在尝试映射 RecordDTO 和 Record。但是当我 运行 应用程序时,抛出异常。
RecordBL recordBL = new RecordBL();
List<Record> record = recordBL.GetAllRecords();
Mapper.CreateMap<RecordDTO, Record>();
List<RecordDTO> recordDTO = Mapper.Map<List<Record>,List<RecordDTO>>ecgrecord);
Mapper.AssertConfigurationIsValid();
return recordDTO;
异常是这样的:
Trying to map System.Collections.Generic.List1[[Server.BusinessEntities.Record, Server.BusinessEntities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] to System.Collections.Generic.List1[[DTOs.RecordDTO,Server.DTOs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].
有人可以帮我解决这个问题吗?
你想映射从记录到记录DTO,所以你需要:
Mapper.CreateMap<Record, RecordDTO>();