简体   繁体   中英

Map column names from a datatable to another datatable in C#

I would like to map a datatable column names from another datatable. Please refer below example. I have 2 datatables returned from database.

在此处输入图像描述

在此处输入图像描述

Please see above 2 tables. The first table contains data and second datatable contains column mapping. I would like to map column names from second table to first table. The final result should be as below.

在此处输入图像描述

You can generate a SQL statement dynamically and end up with:

Select column1 as city, column2 as country,
column3 as population, column4 as tourist
from whatever_table

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