I am mapping with automapper 5.2 from Dto to Model and from Model to Dto. But the problem I have, that have 0 elements when I do the mapping. The two entities are the same.
AutoMapperConfiguration.cs
public class AutoMapperConfiguration
{
public static void Configure()
{
Mapper.Initialize(x =>
{
x.CreateMap<PaisDto, Pais>().ReverseMap();
x.CreateMap<List<PaisDto>, List<Pais>>().ReverseMap();
x.CreateMap<Pais, PaisDto>().ReverseMap();
x.CreateMap<List<Pais>, List<PaisDto>>().ReverseMap();
});
}
}
PaisService.cs
public IEnumerable<PaisDto> GetAll()
{
AutoMapperConfiguration.Configure();
List<PaisDto> dto = new List<PaisDto>();
IEnumerable<Pais> paises = _paisRepository.GetPaisAll();
dto = Mapper.Map<List<Pais>,List<PaisDto>>(paises.ToList());
return dto.ToList();
}
what can happen?