How to check data table contains array of string

I was using this code to filter it but sometimes there is none of string contains my dt and process stop. How can edit the code to use as a condition?

dt = dt.AsEnumerable.Where(function(r) in_ContractNo_Array.Contains(r(“Contract No Column”).ToString)).CopyToDataTable

Hi @EMREUYSAL :wave:

Check the rows in your DT using an if condition like DT.Rows.Count > 0 and inside the then part, use this condition.

It is not possible in my process because without filtering there is always many row inside my dt. But already I found my solution from different topic page in forum
This is the solution I am using
hasContains = dt.AsEnumerable.Any(function(r) yourStringArray.Contains(r(“ColumnName”).ToString()))

Thanks for interesting

2 Likes

That’s awesome @EMREUYSAL :slight_smile: Thanks for sharing your solution here!

1 Like

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