Say I have:
var dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Data Guid", typeof(Guid));
dt.Rows.Add(10, "Jonesy", Guid.NewGuid());
I know I can map this to my custom class Poco
using AutoMapper with:
public class Poco
{
public int ID { get; set; }
public string Name { get; set; }
public Guid DataGuid { get; set; }
}
and
var pocos = AutoMapper.Mapper.DynamicMap<IDataReader, List<Poco>>(dt.CreateDataReader());
But, my column named Data Guid
isn't mapped correctly as there is a space in the name. Is there any way I can tell AutoMapper to remove spaces in column names before the mapping?
I've looked into a custom type converter and using the BeforeMap extension. However I'm unable to alter the schema. Is this possible?
Just to cover all my bases, this is for a much larger project with the data coming from a source I cannot manipulate.