Hi all ,
I want to check DT1 column contains value of column from another DataTable and if it returns Yes ,then I need to update one value , can you please help me to do this in C# Linq query .
For Example
DT1
DT2
output DT should be
if DT1[“Name”] contains DT[“Name”]
then I should Assign DT1["Address]=DT2[“Address”]
I could do that with foreach loop , but its taking more time because of huge data .
Thank you.
Hi @Manchu
Use Invoke VBA Code activity and use the below code
DT1.AsEnumerable().ToList().ForEach(
Sub(row1)
Dim nameToSearch As String = row1(“Name”).ToString()
Dim matchingRow = DT2.AsEnumerable().FirstOrDefault(Function(row) row(“Name”).ToString() = nameToSearch)
If matchingRow IsNot Nothing Then
row1(“Address”) = matchingRow(“Address”)
End If
End Sub)
Note: nameToSearch= Variable is used to search for a matching row in DT2
** Take In argument for nameToSearch varibale (Value to match in DT2)
** Set the Argument for both DT1 & DT2 with In/Out Argument.
Hey Yogeesh ,
I tried it on my code it is not working .will it check dt1Row[“Name”] Contains (dt2Row[“Name”]),but it checks dt1Row[“Name”] ==dt2Row[“Name”]