Hi Folks,
I have two excel sheet I am trying to apply lookup using LINQ.
from dt1 I have fund name column and dt2 MID_FUND_NAME Column it should look up and fetch fund type from dt2 and update Fund code column into dt1
(From a In dt1.AsEnumerable()
Join b In dt2.AsEnumerable()
On a(“Fund Name”).ToString Equals b(“MID_FUND_NAME”).ToString
Select dt3.Rows.Add({a(“Plan#”),b(“FUND_TYPE”)})
).CopyToDataTable
Using these query not able to get fund code from dt2
Please find attached screenshot
For Each row1 As DataRow In dt1.Rows
For Each row2 As DataRow In dt2.Rows
If row1("Fund Name").ToString() = row2("MID_FUND_NAME").ToString() Then
row2("FUND_TYPE") = row1("Fund Code")
End If
Next
Next
For Each row1 As DataRow In dt1.Rows
For Each row2 As DataRow In dt2.Rows
If row1("Fund Name").ToString() = row2("MID_FUND_NAME").ToString() Then
row2("FUND_TYPE") = row1("Fund Code")
End If
Next
Next
For Each row1 As DataRow In DT1.Rows
Dim fundType As String = (From row2 In DT2.AsEnumerable()
Where row1.Field(Of String)("Fund Name").Trim().Equals(row2.Field(Of String)("MID_FUND_NAME").Trim())
Select row2.Field(Of String)("FUND_TYPE")).FirstOrDefault()
If fundType IsNot Nothing Then
row1("Fund Code") = fundType
End If
Next