我正在尝试映射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;
例外是这样的:
尝试映射 System.Collections.Generic.List1 [Server.BusinessEntities.Record, Server.BusinessEntities,Version = 1.0.0.0,Culture = neutral, PublicKeyToken = null]]到 System.Collections.Generic.List1 [DTOs.RecordDTO,Server.DTOs, Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]。
有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
您希望将从记录映射到 RecordDTO,因此您需要:
Mapper.CreateMap<Record, RecordDTO>();