I have three DataTables and Three conditions in which I need to combine into one "Combined" DataTable:
Input:
AddressList
First
Last
Address
City
State
Zip
Offercode
Matrix1
Code
Offer1
Matrix2
Code2
Offer2
Output: (CombinedDataTable)
First
Last
Address
City
State
Zip
Offercode
Offer1
Offer2
My syntax for the these are not working in the "On" and "Concat" portions:
Code:Dim both = From row1 In AddressListDatatable.AsEnumerable() Join row2 In Matrix1Datatable.AsEnumerable() Join row3 In Matrix2Datatable.AsEnumerable() On row1.Field(Of String)("Offercode") Equals row2.Field(Of String)("Code") And On row1.Field(Of String)("Offercode") Equals row3.Field(Of String)("Code2") Select addressListColumnNames.Select(Function(alcn) row1(alcn)).Concat(matrixColumnNames.Select(Function(mcn) row2(mcn))) row1(alcn)).Concat(matrix2ColumnNames.Select(Function(mcn2) row3(mcn2))) For Each result In both CombinedDataTable.Rows.Add(result.ToArray()) Next




Reply With Quote
