0
我有兩個數據表說cSVData和SQLDATA我想比較這兩個數據表的記錄是相同的或不那麼我使用這個查詢動態LINQ查詢的數據表
var matched = from table1 in cSVData.AsEnumerable()
join table2 in sqlData.AsEnumerable() on
table1.Field<string>("GlobalRank") equals table2.Field<string>("GlobalRank")
where
table1.Field<string>("GlobalRank") == table2.Field<string>("GlobalRank")
|| table1.Field<string>("TldRank") == table2.Field<string>("TldRank")
|| table1.Field<string>("Domain") == table2.Field<string>("Domain")
|| table1.Field<string>("TLD") == table2.Field<string>("TLD")
|| table1.Field<string>("RefSubNets") == table2.Field<string>("RefSubNets")
|| table1.Field<string>("RefIPs") == table2.Field<string>("RefIPs")
|| table1.Field<string>("IDN_Domain") == table2.Field<string>("IDN_Domain")
|| table1.Field<string>("IDN_TLD") == table2.Field<string>("IDN_TLD")
|| table1.Field<string>("PrevGlobalRank") == table2.Field<string>("PrevGlobalRank")
|| table1.Field<string>("PrevTldRank") == table2.Field<string>("PrevTldRank")
|| table1.Field<string>("PrevRefSubNets") == table2.Field<string>("PrevRefSubNets")
select table1;
但這個表中的列名必須在where子句中應該採取所有列名
如果您在'「GlobalRank」'上測試,因爲您正在使用連接,您將獲得每個連接行,而其餘條件無關緊要。 – NetMage