I have this mapping defined in my Application Layer:
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;
}
Proffesion entity
public class Profession
{
private int _id;
private string _name;
private Profession(){} // required by nHibernate
public Profession(int id, string name)
{
ParameterValidator.NotNull(id, "id is required.");
ParameterValidator.NotNull(name, "name is required.");
_id = id;
_name = name;
}
public string Name
{
get { return _name; }
}
public int Id
{
get { return _id; }
}
}
Profession DTO:
public class ProfessionDTO
{
public int Id { get; set; }
public string Name { get; set; }
}
When executing GetAllProfessions I get this error:
Signature of the body and declaration in a method implementation do not match.
Any idea why is it happening?
I have just changed all the IList to List. I don't get the exception now but the List of 27 entities of Profession that is retrieved is mapped to 0 of ProfessionDTO.