Merge different types of datatables

Hi, I have got four types of dt’s that I want to merge. I want the combination of columnnames in row1 and row2 to be the ones that it matches on. What can I do to get this as one dt?

image

Hi @Dion

Can you share the expected Output.

Regards

Something like this:

Hii @Dion

Try this Linq:

result = From col1 In dt1.Columns.Cast(Of DataColumn)()
             Join col2 In dt2.Columns.Cast(Of DataColumn)()
             On col1.ColumnName Equals col2.ColumnName And dt1.Rows(0)(col1.ColumnName).ToString() Equals dt2.Rows(1)(col2.ColumnName).ToString()
             Join col3 In dt3.Columns.Cast(Of DataColumn)()
             On col1.ColumnName Equals col3.ColumnName And dt1.Rows(0)(col1.ColumnName).ToString() Equals dt3.Rows(1)(col3.ColumnName).ToString()
             Join col4 In dt4.Columns.Cast(Of DataColumn)()
             On col1.ColumnName Equals col4.ColumnName And dt1.Rows(0)(col1.ColumnName).ToString() Equals dt4.Rows(1)(col4.ColumnName).ToString()
             Select New Object() {
                 col1.ColumnName,
                 dt1.Rows(0)(col1.ColumnName),
                 dt2.Rows(0)(col2.ColumnName),
                 dt3.Rows(0)(col3.ColumnName),
                 dt4.Rows(0)(col4.ColumnName)
             }

I do not understand Linq. How do I assign this to a dt

I know how to read a dt. Work with UiPath since 2017. I do not understand Linq and when i try to assign your code to a DT I get errors.