I'm using AutoMapper plugin to map DataTable to C# Object. Here is my Code:
public List<MyDto> GetReport()
{
List<MyDto> list = null;
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<IDataReader, List<MyDto>>();
});
IMapper mapper = config.CreateMapper();
list = mapper.Map<IDataReader, List<MyDto>>(Odao.Inst.GetReport().Tables[0].CreateDataReader()).ToList();
return list;
}
My MyDto class looks like this
public class MyDto
{
public int EmployeeId { get; set; }
public string FullName { get; set; }
}
Here, data is properly returning from my DataAccess Layer but when It maps to Object, list is coming as empty. Am I missing anything here?