简体   繁体   中英

Convert List<POCO> to Datatable in C#.NET

I am looking for the cleanest way availble to convert a List into a datatable.

I came across some articles which was basically combination of Foreach +Reflection. Not a bad option IF there is no other cleaner way to do it. After some research I came across this article which uses Auto-mapper to hydrate objects from data table:

http://www.geekytidbits.com/automapper-with-datatables/

I am wondering if exactly opposite is possible

Why do you want to do this?

You can find a library that can help: FastMember

Or, you can write something up using reflection.

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