I have an urgent issue and hope you can help me out.
I’m struggeling with the creation of a value-expression which I need to remove data rows from a data table. In this value expression I want to select the rows from a data table collectedDataDT where the first column (Entry_ID) matching the same values from column (Entry_ID) of data table called joinEntIDDT. → like a lookup
What I am trying to do:
1:
I assigned “data_to_del” (as System.Data.DataRow) to a value expression which I do not know how to write.
2:
then I use “For Each” activity to loop trough the items of data_to_del. In the body of this “for each”-loop I will remove data rows from a data table. (see screenshot)
Question: How to write this filter expression in the assign activity.
@BOTFORCE You can use this Linq Query to get the Non Matching Records :
Use the Below Expression in an Assign Statement in this way:
CollectedDataDT = CollectedDataDT.AsEnumerable().Where(function(row) Not joinEntIDDT.AsEnumerable().Select(function(x) x(“entry_id”).ToString).Any(function(y) y = row(“entry_id”).ToString)).CopyToDataTable()
You won’t be needing the Data Row Variable or the For Each to Remove the Rows
@BOTFORCE Actually there is an additional Step involved in it, Which I believe I have not said. When the CollectedDataDT has no rows Corresponding to entry_id which is matching in Other DT , it gives out an Error.
There are mainly two ways of Handling that error:
You can use a Try Catch Method, Where you enclose the Assign Statement in Try and use another assign Statement in Catch Block to assign an Empty Datatable. You can perform thsi as shown in the Screenshots below
The Other method is to use an Array of DataRow variable. You can Declare an Array of DataRow variable, say dtRow_array. Instead of the Query above you can use this Query :
dtRow_Array = CollectedDataDT.AsEnumerable().Where(function(row) Not joinEntIDDT.AsEnumerable().Select(function(x) x(“entry_id”).ToString).Any(function(y) y = row(“entry_id”).ToString)).ToArray