ADO.NET extensions for AutoMapper
$ dotnet add package AutoMapper.Datavar mapper = new Mapper(cfg => {
cfg.AddDataReaderMapping();
cfg.CreateMap<IDataRecord, MyDto>();
cfg.CreateMap<IDataRecord, MyOtherDto>();
// Other config
});
// or with the AutoMapper.Extensions.Microsoft.DependencyInjection package:
services.AddAutoMapper(typeof(Startup), cfg => {
cfg.AddDataReaderMapping();
});
You will need to configure maps for each IDataRecord DTO mapping.
Profile:There are several ways to configure mapping with an instance of Profile:
Profile.AddDataRecordMember extension method on it, and add it to the configuration.AddMemberConfiguration().AddMember<DataRecordMemberConfiguration>() on the instance.IMapperConfigurationExpression.AddDataReaderProfile extension method.