I’m getting the following error in an Assign when using a LINQ filter that sometimes returns no matching rows:
Assign - dt_temp: The source contains no DataRows.
My current expression:
dt_temp = dt_build.AsEnumerable().Where(Function(x)x(“Name”).ToString.Contains(“C”)).CopyToDataTable
Show more lines
This works when matches exist, but fails when there are 0 rows because CopyToDataTable() requires at least one DataRow.
I want to fix this within the same Assign (no extra query or additional Assign activity), ideally by returning an empty DataTable with the same schema when there are no matches.
Hi @ASHUTOSH_DUBEY2
Welcome to community
Take assign activity and pass it
dt_temp =
If(
dt_build.AsEnumerable().
Any(Function(x) x(“Name”).ToString.Contains(“C”)),
dt_build.AsEnumerable().
Where(Function(x) x(“Name”).ToString.Contains(“C”)).
CopyToDataTable(),
dt_build.Clone()
)
Hope it resolve your issue
Cheers
1 Like
Hi @ASHUTOSH_DUBEY2 ,
If row exist → filtered DataTable is returned.
If no rows exist → an empty DataTable with the same schema is returned.
No extra assign or activities required.
system
(system)
Closed
December 20, 2025, 8:07am
5
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.