LINQ query for update column value based on condition

Hi all,
I want to update the state column to “AP” when Location is “Vizag” and to “TS” when Location is “KarimNagar” using method syntax. Please anyone guide me.

@JK_MECH,

Use this LINQ in Invoke Code activity.

dt.AsEnumerable().ToList().ForEach(Sub(row)
    If row.Field(Of String)("Location") = "Vizag" Then
        row.SetField("State", "AP")
    ElseIf row.Field(Of String)("Location") = "KarimNagar" Then
        row.SetField("State", "TS")
    End If
End Sub)

Before:

After:

@ashokkarale
thank you sir,

1 Like

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