I am using the following LINQ query to get rows that exists in DT1 but not in DT2:
The problem is when the datatables are identical(no missmatches) then I get the Error: “Assing: The Source contains no DataRows”.
I tried to wrap it around an IF statement that checked if it was Null but that does not work.
How can I make it so when the LINQ query doesnt find any missmatch to assing a variable the value FALSE.
Can you please follow below link?
I guess you will find a solution there if not, please let us know…
we can handle retrun results with following pattern
CopytoDataTable is throwing an exception in case of no rows are returned / forwarded to the method. But with checking on this before using CopytoDataTable we can handle this in a defensive way
@ppr im not 100% sure if im on the same page.
Do I need to convert my datatable to a List first?
Because with the Linq Query im using above I am comparing 2 datatables.
I cant see how the Linq Query you wrote compares the two datatables?
I have not merged the datatables.
Is there a way to make it that when
DT1.AsEnumerable().Except(DT2.AsEnumerable, DataRowComparer.Default).CopyToDataTable throws an exception then assign it a value.
then check the count as done in the pattern
based on the check you execute the CopyToDataTable
Your clone it to reveive an empty datatable within the same column structure
@ppr Thank you. Works great.
So lists are easier to work with it seems.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.