Error While Using a LINQ query

Continuing the discussion from Excel Vlookup Using UiPAth:
@MAHESH1
I tried using the LINQ query ,it gives me the below mentioned error
"Range variable name cannot match the name of a member of the ‘object’ class "
Could you please help me out here?

Regards

@iVishalNayak
mabye you post some sample data from your dataset with a short output description. We will take this for the LINQ development. Thanks

1 Like

@ppr
image Main Data Table used for reference
image Data Table to compare with Main Data table
if AccNo from second dt matches with mainDt we compare the name and Address ,and update the status.
AS of now I am Using Lookup DT(Activity) with For Each Row, I feel LINQ is faster.
Regards.

@Manish540
Any LINQ query for this? or any other method which is Quicker?
Regards.

give a first try on join datatable.
if it is not doing as expected then we go ahead with LINQ

have a look here as well

1 Like

@ppr
if JOIN is used order of rows are changed , and I want to update in the same DT('Status" Column)without any change in order of rows.

Regards.

Hi @iVishalNayak

Below is the workflow for the same :-
MainPratik.xaml (11.0 KB)
New Microsoft Excel Worksheet.xlsx (9.4 KB)

Linq :-

readSheet2.AsEnumerable.ToList.FindIndex(Function (r) (r(1).ToString+r(2).ToString+r(3).ToString).Equals(row("Name").ToString) And r(0).toString.Equals(row("AccNo").ToString) And r(4).toString.Equals(row("Address").ToString)) 

Input :-

Output :-

Note :- I have put the Status as “Correct”

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

2 Likes

@iVishalNayak
Kindly note the referenced case is less complex as it checks only for one Value without any concatenations (Name Cols) and multiple Cols (Name, Adress). Also it has the potential to reduce it with an Any Statement. Also it is not updating any columns in a table

In real scenario we also have the risk that the Name split will increase the complexity on additional.

However task can be solved on:

  • Join Approach
  • Filter Approach

For the Join Approach the Join Data Table is a good start

  • left join dtData TO dtMain
  • Selecting the result can be done with a LINQ, Also resorting the cols on AccNo INTs in the same statement

Find Demo XAML here:
iVishalNayak_JA-Approach.xaml (11.9 KB)

For the Filter Approach

  • for the check we can rely close to this what was done above in the filter LINQ

Find Demo here:
iVishalNayak_LINQ-Approach.xaml (10.8 KB)

For fast Prototyping both will work fine. For Production use it is more recommended to find some balanced approache by combining different buuilding blocks (For Each, Join, Filter…) to enforce the possibilty to maintain and to track.

1 Like

Does the job! but no difference in execution TIME .(I am using LOOKUP datatable Activity)

Thanks for the LINQ query.

@Pratik_Wavhal

Thanks @ppr

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