Search code examples
genericsdatasetautomapperstrongly-typed-datasetgeneric-list

I am thinking about using automapper to translate a typed dataset to a generic List of objects


Actually I want to return a generic list of certain types bases on a typed dataset. I know the type in my method, so I can use some kind of generic code to call to do the translation.

So currently my methods return typed datasets, but they should return generic lists. I am thinking about using Automapper, but the time (because of upcoming holidays) lacks to create some prototypes. So I would really like to read about your experiences.

Any other suggestions on how to realize my goal are very welcome. This way I might learn of an even better way to complete my task.


Solution

  • Here is a solution:
    http://house9.blogspot.com/2010/11/automapper-datatable-to-list.html

    AutoMapper.Mapper.CreateMap<IDataReader, Person>();
    
    IList<Person> people = AutoMapper.Mapper.Map<IDataReader, IList<Person>>(dt.CreateDataReader());