1

I'm trying to map from IDataReader into Person but I always get 0 results: https://github.com/AutoMapper/AutoMapper/issues/874

Profile:

internal class ImportAddressProfile : Profile
{
    private readonly IContainer _container;

    public ImportAddressProfile(IContainer container)
    {
        _container = container;

        CreateMap<IDataReader, Person>();
       CreateMap<IDataReader, List<Person>>();
    }
}

public class Person
{
    public string FirstName { get; set; }
    public int Amount { get; set; }
}

Run: ...

var dt = new DataTable();
dt.Columns.Add("FirstName", typeof(string));
dt.Columns.Add("Amount", typeof(int));
dt.Rows.Add("John", 123);
dt.Rows.Add("Bob", 2);

IDataReader reader = dt.CreateDataReader();
List<Person> People = Mapper.Map<IDataReader, List<Person>>(reader);

// returns zero results

I've already tried adding nuget package: https://www.nuget.org/packages/automapper.data

ShaneKm
  • 20,823
  • 43
  • 167
  • 296

1 Answers1

1

AutoMapper.Data is not supported in AutoMapper 5. I broke out that into its own repository, mainly because I don't use it and don't have the foggiest idea of what the code does. If you're interested in getting it working, I'm happy to accept a PR from anyone who gets it working with AutoMapper 5.

Jimmy Bogard
  • 26,045
  • 5
  • 74
  • 69