Linq for datatable

image
I need to check if any row in Status column is New. If it is new then I will use throw activity else continue the process.
Can you please provide linq for the mentioned case?

Hi

Use this expression in a IF condition

dt.AsEnumerable().Where(Function(a) a(“Status”).ToString.ToUpper.Contains(“NEW”)).CopyToDatatable().Rows.Count>1

If true it goes to THEN block where use a THROW activity
If not it goes to ELSE block

If you want to look for each row and send exception then iterate each row with a FOR EACH ROW activity and pass dt as input

Inside the loop use a if condition like this

CurrentRow(“Status”).ToString.ToUpper.Contains(“NEW”)

If true goes to then block where send the exception with THROW

hope this helps

Cheers @Tanmay_V_Chetule

Hi,

How about the following?

dt.AsEnumerable.Any(Function(r) r("Status").ToString="New")

image

Regards,

@Tanmay_V_Chetule

dt.asenumerable.where(function(x) x(0).tostring.tolower.equals(“new”))
if true throw error
else continue process

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