Need Help with creating linq query

Hi , I have
DT1
image
DT2
image
I want the ouput
image

I want to if check DT1 column[FullName]contains DT2 column[Name] and if it contains I want to update DT1 Column[Number] with DT2 column[Number].
For eg : “Thomas Ball” from DT1 contains Name “Ball” from DT2 ,so I should get the Number column from DT2 and add it to DT1 Number Coulumn .
Can anyone please help me with writing Linq query for this .Thank you.

@Manchu

hi try this using invoke code

For Each r1 As datarow In dt1.AsEnumerable
For Each r2 As DataRow In dt2.AsEnumerable
If r1(0).ToString.trim.Contains(r2(0).ToString.trim) Then
r1(2)=r2(1).ToString.Trim
Else
End If
Next
Next

hope this helps

Sequence2.xaml (14.3 KB)

check this workflow for reference

Hi thank you Shiva,I am using C# language

@Manchu

in the invoke code you can change the language i think can try by making it to vb.net

image

@Manchu
Keep in mind that contains can lead to an unclear match as well

d1
John Smith, xxx
Jeff Johnson, xxx
Sandra Page, xxx

d2
John, 123
Page, 456

we would match John to John Smith and also Jeff Johnson when working within a contains.

Let us know, if you want at least detect such cases

This is just an example , my scenario exactly like this .

ok perfect.

When there is a further interest on a LINQ approach we recommend to have a look at:

  • generals
  • First / FirstOrDefault Operator

Find some training help here:

Thanks Shiva , it worked .

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.