Linq to compare two datatables using two keys - error

Hi Together,

I try the same as described in this post: Linq to compare two datatables using two keys - Learn - UiPath Community Forum.

  • Read data table 1
  • Read data table 2
  • Compare 4 columns and find non matches using the formula

DT_Heute.AsEnumerable().Where(Function(row) Not DT_Vortag.AsEnumerable().Where(function(r) r(“PO”).ToString.Equals(row(“PO”).ToString)and r(“Artikel”).ToString.Equals(row(“Artikel”).ToString) and r(“ETD best.”).ToString.Equals(row(“ETD best.”).ToString) and r(“ETD Wunsch”).ToString.Equals(row(“ETD Wunsch”).ToString)).Any).CopyToDataTable

I get the error message below. Translation: Compilation of VisualBasicValue’1 is required. Make sure the workflow has been compiled.

Assign - Nur nicht Matches behalten: Zum Ausführen des Ausdrucksaktivitätstyps “VisualBasicValue`1” ist eine Kompilierung erforderlich. Stellen Sie sicher, dass der Workflow kompiliert wurde.

Thanks!

Hi @PeCour ,

Could you try outputting it to a List of DataRows first, before copying it to a DataTable?
This is to verify whether the filtering returns at least one row, because DataTables don’t like it when you try to feed it null values, he can be quite greedy.

(From row In DT_Heute.AsEnumerable()
Let chk = DT_Vortag.AsEnumerable().Where(function(r) r(“PO”).ToString.Equals(row(“PO”).ToString)and r(“Artikel”).ToString.Equals(row(“Artikel”).ToString) and r(“ETD best.”).ToString.Equals(row(“ETD best.”).ToString) and r(“ETD Wunsch”).ToString.Equals(row(“ETD Wunsch”).ToString)).ToArray()
Where chk.Count()>0
Select row).ToList()

Next, check if the List of DataRows are contain any values like so:

lst_checkValues.Count() > 0

Then →

(From row In DT_Heute.AsEnumerable()
Let chk = DT_Vortag.AsEnumerable().Where(function(r) r(“PO”).ToString.Equals(row(“PO”).ToString)and r(“Artikel”).ToString.Equals(row(“Artikel”).ToString) and r(“ETD best.”).ToString.Equals(row(“ETD best.”).ToString) and r(“ETD Wunsch”).ToString.Equals(row(“ETD Wunsch”).ToString)).ToArray()
Where chk.Count()>0
Select row).CopyToDataTable()

Could you try that and let us know if it works out for you?

Kind Regards,
Ashwin A.K

lets seperate LINQ from issue

we do see such issues a few times back in newer package versions, while the shift is ongoing to the different served target platforms

About the LINQ we would recommend to share some sample data with us. So we can check for realignment the LINQ and checking the option of reducing the predicted operations e.g. caused by the Where part

Hi @ashwin.ashok,

thank you for your help. I tried it but I received the same error message for the function that you gave me. Therefore I believe it might really be a separate issue like @ppr wrote.

I tried it out on a different data basis as well where I only left two data rows in each table without any null data values. I still got the same issue. And sorry but I can’t share the data :confused:

I randomized the data so the data looks like that:

Supplier PO Artikel xc_ETD_Termin ETD Wunsch ETD best. ETD ist
123 1 567 02.05.2022 02.05.2022 03.05.2022 nicht gepflegt
1234 2 7678 02.05.2022 02.05.2022 02.05.2022 nicht gepflegt

And in the other table, it is the same. I only changed the date.

For the LINQ find starter help here:
FindMatchesNonMatches_ColSetCheck_SequenceEquals_V2.xaml (15.2 KB)

We had defined an array with the ColumnNames which are used for the check
grafik

And using the Any and SequenceEqual Approach for getting dt1 rows which are not present in dt2 evaluated on the columns from the colset

(From d1 In dt1.AsEnumerable
Let ma = FilterColSet.Select(Function (x) d1(x)).toArray
Where Not dt2.AsEnumerable.Any(Function (r) FilterColSet.Select(Function (x) r(x)).toArray.SequenceEqual(ma))
Select r=d1).toList

About the Excpetions please let us know:

  • UiPath Studio Version and Edition
  • Version of the UiPath.System.Activities package
  • a screenshot where the LINQ is used
  • Modern design enabled

Also ensure that there is no any other invalid XAML within the project

1 Like

Hi @ppr,

thank you for your effort. I used your file to test my initial linq sequence and it worked.
Then I created a new project and rebuild my previous one and it worked as well.

The only difference was that I changed from windows to windows legacy:
Usually I always use windows legacy but due to a different bug in sharepoint integration (office 365 activities) one of UiPath support man advised me to use windows projects.

The previous project had:

  • The same activity package versions
  • Modern design enabled
  • and no other XAML in the project

But the compilation took for ever in contrast to other projects. Therefore, maybe there was a bug in the XAML file itself.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.