Linq for datatable and if conditions


Is there any way to use Linq here?
Please mention the queries.
Thanks in advance

Hi

Hope this expression helps you

dt = dt.AsEnumerable().Where(Function(a) a(“column-0”).ToString.Contains(“Oxygen”) AND Comvert.ToInt32(a(“column-1”).ToString.Trim)>88).CopyToDatatable()

Now use a if activity with condition like this
dt.AsEnumerable().Any

If true in THEN block use a THROW activity with exception u want

Hope this helps

Cheers @Tanmay_V_Chetule

Why change to Linq? What you’ve done is simple and correct, although you don’t need the nested If…just change the first If to…

row("Column-0").ToString.Contains("Oxygen") AND CInt(row("Column-1").ToString) > 88

Note that your second if condition isn’t correct because you’re missing the .ToString on the end of the row(“Column-1”)

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