Trying to map System.Collections.Generic.List 1 Exception is thrown

3.4k views Asked by At

I am trying to map RecordDTO and Record. But when I run the application, an exception is thrown.

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;

The exception is something like this:

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]].

Could some one help me out with this?

1

There are 1 answers

1
nvoigt On BEST ANSWER

You want to map from Record to RecordDTO, so you need:

Mapper.CreateMap<Record, RecordDTO>();