The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Tuesday, November 16, 2010

Automapper Datatable to List

I did a few Google searches for "c# automapper datatable to list" but nothing good showed up right away, maybe this post will help someone in the future?

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



Note that we are actually mapping IDataReader to a list, and DataTable has convenience method to do that for us 'CreateDataReader'


1 comment:

happyapostate said...

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.