LINQ to query DataTable from Config value?

Hi there,

I have a value in my Config file (Dictionary of String,Object)

InvalidFlags = “X,Y,Z”
(flags which are comma separated)

In my process, I retrieve a DataTable which may come back like this:

Col1 | Col2 | Col3
Test | Test | A
Test | Test | X
Test | Test | B

I would like to throw a Business Exception because the “X” is found on any row in Col3, and is one of the nominated ‘Invalid Flags’ in the config value. How can I achieve this using LINQ statement?

Assign activity:
arrFlags = invalidFlags.Split(","c).Select(Function (x) x.Trim).toArray

Assign activity:
hasInvalidFlags | Boolean =

(From d in YourDataTableVar.AsEnumerable()
Let v = d("Col3").toString.Trim
Where arrFlags.Contains(v)
Select r=d).Any()

You are an RPA God, thank you so much for the quick reply! Works perfectly. I am sure this is a common query to use, will save it for future reference and hopefully learn more about LINQ query in the meantime. Thankyou :slight_smile:

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