views:

83

answers:

3

I'm using AutoMapper which is a great tool.

There's lots of examples converting from DataTable/IDataRead to DTO's but I can't seem to find any that convert the DTO back to a DataTable.

Is this possible? I've tried various things, but I think there's some difficulty with the creation of Rows - as you can't new them up.

+2  A: 

Not right now out of the box. What you COULD do is create a new IObjectMapper. Take a look at the DataReaderMapper.cs in the source code (found on github), and build the opposite direction. If you get it to work, I'll gladly fold what you get back into the project, because it sounds like a really interesting idea.

Jimmy Bogard
Thanks Jimmy. I've been taking a look today and it looks as though the enumerable mapper is better suited. I know I'm probably wrong though! Also, I'm not sure if the IL generated stuff is needed as we'd be mapping from a strongly typed object into a DataTable. Wouldn't mind a bit of help if you've got time. I'll buy you beer 'till it comes out of your ears if we meet some-day at a conference or something! :)
Steve Dunn
A: 

Hi Steve, I am facing the same problem as you... Did you ever get it going? I would be most interested to hear if and how you got it going...

Pelle