简体   繁体   中英

How do I use AutoMapper to populate back to a DataTable?

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 Row s - as you can't new them up.

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.

I forked it in GIT; Jimmy Bogard may be looking to merge it in during the next major version.

You can get it here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM