Mapping DataTables to domain objects

It’s always a pain to work with DataTables and DataSets. You’re always typing these pesky column names, it doesn’t necessarily represents the actual data model (if there are nested data), there is no type safety until runtime, it’s pretty hard to use Linq on your results… the list goes on.

Fortunately, there is a simple solution: AutoMapper. It’s very simple to cast a DataTable to a list of objects: