I have the following function:
Public Function Check_Desparity(Byval dtTestStep as DataTable, Byval dtLimits as DataTable) as DataTable
Dim diff = dtTestSteps.AsEnumerable.Union(dtLimits.AsEnumberable).Except(dtTestSteps.Intersect(dtLimits.AsEnumerable))
End Function
I expect, that diff contains the rows with differences. But it doesn`t. I have two differences, but diff contains only one and that one is no difference.
When I try the same thing with List(Of String)
instead of DataTable
it works perfect.
Public Function Check_Desparity(Byval TestStep as List(Of String), Byval Limits as List(Of String)) as List(Of String)
Dim diff = TestStep.Union(Limits).Except(TestStep.Intersect(Limits))
End Function
Here I get exactly the two differences of both lists back in diff.
Could somebody explain me why? Thank you
EDIT:
With help of you, I got exactly what I wanted. The function for my answer is the following:
Public Function Check_Desparity(Byval dtTestStep as DataTable, Byval dtLimits as DataTable) as IEnumerable(Of DataRow)
Dim diff = dtLimits.AsEnumerable.Except(dtTestSteps.AsEnumberable, DataRowComparer.Default)
Return diff
End Function
But I forgot to mention an important detail.
This function works only if both of the tables have the same columns.
In my case, the columns are different, but column "dictkey". Column "dictkey" exists in both of my datatables.
How I get it to work, that my function returns only rows, where "dictkey" is different respectivly not existent?