Formatting a query to enumerate through 2 different datatables

Posted by boiler1974 on Stack Overflow See other posts from Stack Overflow or by boiler1974
Published on 2012-12-12T19:31:47Z Indexed on 2012/12/13 17:03 UTC
Read the original article Hit count: 260

Filed under:
|
|

I have 2 datatables

sendTable and recvTable

They both have identical column names and numbers of columns

"NODE" "DSP Name" "BUS" "IDENT" "STATION" "REF1" "REF2" "REF3" "REF4" "REF5" "REF6" "REF7" "REF8"

I need to compare these 2 tables and separate out the mismatches

I only need to check Columns 3-11 and Ignore col 1 and 2

I tried at first removing the 2 columns and then loop thru row by row and return matches and mismatches but the problem with this approach is that I no longer have the "NODE" and "DSP Name" associated with the row when I finalize my results

So I need help with a query

Here is my attempt

var samerecordQuery = from r1 in sendTable.AsEnumerable()
                      where r1.Field<int>("BUS").Equals(from r2 in recvTable.AsEnumerable() where r2.Field<int>("BUS"))   

this obviously doesn't work so how do I format the query to say

from r1 cols[3-11] equals r2 cols [3-11] 

and once I have this I can use the except to pull out the mismatches

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ