Update one column value with another column value using linq query

Hi everyone,

My requirement i have an excel with many columns

if ‘relationship type’ column is ‘o&p’ and then i have to update that cell value with other column from same datatable ‘job relation career name’ for all the matched rows using linq query @Rahul_Unnikrishnan @Palaniyappan @Yoichi

Thanks in advance

Hi,

How about the follwing using InvokeCode activity?

dt.AsEnumerable.Where(Function(r) r("relationship type").ToString ="o&p").ToList.ForEach(
Sub(r) 
     r("relationship type")=r("job relation career name").ToString
End Sub
)

Regards,

Hello @kavya.s16

Please provide a screenshot of the input file and the expected output to get more clarity on the requirement.

1 Like

thanks @Yoichi but how can i use above query for comparing two datatables

  1. I need to compare 'employee id ’ from two datatables , then filter with ‘relationship type’ =‘o&p’
    2.if no. of rows is 1 then
  2. update datatable 1 'o&p column value with datatable 2 ‘job relation career name’

datatable 1

datatable 2

For Each row as Datarow in DT.Asenumerable
row(“job relation career name”)=If(row(“relationship type”).To string.Trim.Equals(“O&P”),row(“relationship type”).ToString,row(“relationship type”).ToString)
Next

Use This in : Invoke Code Activity

1 Like

sorry @Rahul_Unnikrishnan since its client confidential data i will not be able to provide excel

  1. I need to compare 'employee id ’ from two datatables , then filter with ‘relationship type’ =‘o&p’
    2.if no. of rows is 1 then
  2. update datatable 1 'o&p column value with datatable 2 ‘job relation career name’

@Gangadhar_Athili how to compare for two datatables?

Hi,

Can you try the following sample?

Dim dict As Dictionary(Of String,String) = dt2.AsEnumerable.ToDictionary(Function(r) r(0).ToString,Function(r) r(1).ToString)
dt1.AsEnumerable.Where(Function(r) r("relationship type").ToString.Contains("O&P")).ToList.ForEach(
Sub(r) 
    If dict.ContainsKey(r("employee id").ToString) Then
         r("o&p bp career name")=dict(r("employee id").ToString)
    End If
End Sub
)

Sample20220609-2.zip (3.0 KB)

Regards,

@yochi thanks

there is one more scenario where

where bot has to match 'employee id ’ from two datatables
1.then filter with 'relationship type ’ = o&p in datatable 2
2. if now of rows =1 then update datatable 1 ‘o&p career name’ column with ‘job relationship career name’ from datatable 2
@ppr @Palaniyappan @Yoichi @Rahul_Unnikrishnan
thanks