Linq to check

The below linq checks if the word from dt is present inside the Input string .It checks for exact match .I need to modify such that it gives true when the complete dt word is present ArrTarget .

dt.AsEnumerable().Any(Function(r) r.ItemArray.Any(Function(o) arrTarget.Contains(o.ToString(), StringComparer.OrdinalIgnoreCase)

For example .
Dt word
order
miss
return

ArrTarget=[“Ordering” “the” “cake”]

Output is “True” .As dt contains “Order”

I need to check word from dt is present inside the ArrTarget not the other way around .

Hello @tharaninatarajan1901 Try below:

dt.AsEnumerable().Any(Function(r) (From val In arrTarget Where r.ItemArray.Any(Function(o) val.Contains(o.ToString,StringComparison.OrdinalIgnoreCase))).Count > 0)

Thanks .I get validation error strict implicit conversations rom string to char Value od type system.string.comparision cannot be converter to system.collection.generic.IequalityComparer(Of Char)

working fine for me.
Can you test the attached file.
Test.xaml (10.6 KB)

It works fine in my personal laptop .But in my office latptop it shows error .Am i missing something

I am able to open the solution in my Community edition whereas in enterprise editin when tried to open it says document failed.Can u help plese

You are not able to open the test file ? You must keep test xaml file in already existing project to open it.

If you still face issue try restarting the UiPath Studio
Try to create new project in your office UiPath Studio then try to use the linq. If it works then there could be issue with your project

if all above fails then try to reinstall the UiPath Studio.

I m not sure what the issue with string comparison in my office studio .I changed the code to dt.AsEnumerable().Any(Function(r) (From val In arrTarget Where r.ItemArray.Any(Function(o) val.Contains(o.ToString))).Count > 0)

Although it is working fine It has become case senstive .Can you suggest a way to ignore Case

try below. This will convert all char to lower case and then match it.
dt.AsEnumerable().Any(Function(r) (From val In arrTarget Where r.ItemArray.Any(Function(o) val.ToLower.Contains(o.ToString.ToLower))).Count > 0)

1 Like

Thanks a lot!!! .It worked

1 Like

I also need to get which word/words that got matched from the Datatable . Is to possible to retrieve that too?

yes it is possible… though LINQ for this is bit different, try below:

(from val in arrTarget where dt.AsEnumerable().where(Function(r) r.ItemArray.Any(Function(o) val.ToLower.Contains(o.ToString.ToLower))).Count > 0 select x =val)

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