I have this mapping defined at my application level:
public IList<ProfessionDTO> GetAllProfessions() { IList<Profession> professions = _professionRepository.GetAll(); Mapper.CreateMap<Profession, ProfessionDTO>(); Mapper.CreateMap<IList<Profession>, IList<ProfessionDTO>>(); IList<ProfessionDTO> professionsDto = Mapper.Map<IList<Profession>, IList<ProfessionDTO>>(professions); return professionsDto; }
Suffix
public class Profession { private int _id; private string _name; private Profession(){}
Profession DTO:
public class ProfessionDTO { public int Id { get; set; } public string Name { get; set; } }
When executing GetAllProfessions, I get this error:
The body signature and declaration in the implementation of the method do not match.
Any idea why this is happening?
I just changed the entire IList to List. Now I am not getting an exception, but the list of 27 Profession objects that are retrieved is mapped to 0 from ProfessionDTO.
source share