I have two asp.net datatables, each with a UserID field. I need to return a count of those from table1 that are in table2. Example:
Table1: Userid 123, 456, 789
Table2: UserID 789, 456
The result should be a count of 2 (789 and 456).
Table1 and Table2 could have thousands of records. I am looking for the most efficient way to return the result, asp.net, vb.net. I have looked at Linq but have never used it, not sure if this helps...
How to detect that a datatable is a part of another datatable
This almost works. It gives me 123. Does anyone know how I can get the 456 and 789?
Dim dt3 As DataTable = dt_users.[Select]().Where(Function(x)
Not dt.[Select](String.Format("UserID = '{0}'", x("UserID"))).Any()).CopyToDataTable()
'get returned UserID
For Each row As DataRow In dt3.Rows
Dim user As String = row("UserID")
Next