I want to use custom LINQ to inner join 2 data tables due to the functionality of “OR” that UiPath cant work on. However, an error occurs saying “Assign: Object reference not set to an instance of an object.” using the code below. Would anyone help me, please?
(From d1 In dt1.AsEnumerable
Let jr = dt2.AsEnumerable.Where(Function (d2) d1("id").toString.Trim.Equals(d2("ID").toString.Trim) Or d1("Passport").toString.Trim.Equals(d2("Passport").toString.Trim))
From j In jr
Let ra = d1.ItemArray.Concat(j.itemArray).toArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
For the columns matching:
dt1 = “id”, “Passport”
dt2 = “ID”, “Passport”
whereas dtResult is the variable to save the result
when setting up a LINQ in this way we do need the prepared dtResult. But we can also dynamize its generation. So we are flexible and prepared on varying data column structures.
different strategies:
Datatable Merges on datatable.Clone
for each and dynamized setup the target column structure by processing dt1, dt2
…