Assign Datatable: Value cannot be null. (Parameter 'source') AsEnumerable()


the assign activity often works but not now for reasons I understand.
I have error : Assign: Value cannot be null. (Parameter 'source')

the assign expression is : dt_extractFromCsv.AsEnumerable().Where(Function(row) NOT dt_controlDuplicateEntry.AsEnumerable().Any(Function(x) x("Id").ToString=row("Id").ToString)).CopyToDatatable

The .Any returns a boolean telling you if any rows matched the query, it doesn’t return a data set.

If all you’re trying to do is filter the datatable by Id then just use the Filter Data Table activity.

but before it works like that, I didn’t touch the code

Then what’s happening is the expression is returning 0 records which causes .CopyToDatatable to fault.

Use the Filter Data Table activity and then this won’t happen. If no results match, then the resulting datatable will contain 0 rows, it won’t generate an error.

what i manage here ?

Wait, are you trying to find rows from one datatable where the Id exists in another datatable? For that you would use Join Data Table, set it to left join, and set it to “Id” (left table) equals “Id” (right table).

@GRAYAA_Noussaier

basically when the where condition returns 0 rows you would see this issue

so as a fall back first use an if condition with .count>0 and on then side use copytoDataTable and on else side as there are no rows just use dt_extractromCSV.Clone()

this would handle the error

cheers