我查詢兩個數據庫,試圖加入結果集並使用LINQ查詢它們。看起來這將是一件容易的事,但如果沒有明確的加入,我會遇到重大的性能問題。當我進行顯式連接時,我無法使用VB語法來創建明確的類型。工作代碼,已清理:LINQ加入數據表,兩個無類型字段
For Each CurrRow In ResultsA.Tables(15).Rows
CurrDate = CurrRow("Date")
CurrID = CurrRow("ID")
CurrVal = CurrRow("Val")
Dim ResultsB = From SMW In DataSetA.Tables(0).AsEnumerable() _
Where SMW("ID") = CurrScheduleID And SMW("Time") = CurrProfileDate _
Select UTC_TS = SMW("Time"), Value = (SMW("VALUE")/1000), Time_Zone = SMW("Time_Zone"), ID = SMW("ID")
Dim CurrentResult As Object
Dim boolSchedDateFound As Boolean = False
For Each CurrentResult In ResultsB
If CurrentResult.Value <> CurrVal Then
'LogIntegrityCheckErrorRow()
End If
boolSchedDateFound = True
Next
Next
這需要FOREVER以100,000行運行。
我一直在試圖改寫這個爲:
Dim MismatchRows = From TableAData In DataSetA.Tables(0).AsEnumerable() Join TableBData In DataSetB.Tables(15).AsEnumerable() _
On New With {.TableAID = Convert.ToInt32(TableAData("ID")), .TableATime = Convert.ToDateTime(TableAData("Date"))} _
Equals New With {.TableBDID = Convert.ToInt32(TableBData("ID")), .TableBTime = Convert.ToDateTime(TableBData("Time"))} _
Select .................. (Hard to clean up, but this isn't the part that's failing)
,我有與它一個時間熊。根本問題是缺乏強有力的打字。我看了,但似乎沒有什麼建議,因爲大多數人這樣做會在數據上建立EF。這不是一個可怕的想法,但需要大量的重新設計。所以。問題在我面前,我如何消除錯誤:
'Equals' cannot compare a value of type '<anonymous type> (line 2641)' with a value of type '<anonymous type> (line 2642)'.
非常感謝您的幫助。