The solution showed up on stackoverflow here is the link
http://stackoverflow.com/questions/2429194/automapper-mapping-ienumerable-to-datareader-issue
and here is a code snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.Data.DataTable people = GetPeopleData(); | |
AutoMapper.Mapper.Reset(); | |
AutoMapper.Mapper.CreateMap<IDataReader, Person>(); | |
var results = AutoMapper.Mapper.Map<IDataReader, IList<Person>>(people.CreateDataReader()); |
Note that we are actually mapping IDataReader to a list, and DataTable has convenience method to do that for us 'CreateDataReader'
2 comments:
Thanks House9. I've added an extension method to DataTable using your code, and it works fine. Now I just call ToList with the appropriate type for the records and away we go.
Hi friend,
Do you have a suggestion to ignore the Case Sensitiveness in Auto Mapper. because i am using the AutoMapper to map dataTable data with class object as you wrote in sample.
But , since i am using the Hana database and it returns the table with UpperCase Columns names. Then auto mapper doesn't function as usual.
if you can give me a help please let me know.
Thanks
Post a Comment