How do i update an entire column in a Datatable using LINQ operation?

Hi Team,

Can you please suggest a linq operation to perform this operation?
Input:

Name Age
A 23
B 22
C 24
D 25
E 21

Output:

Name Age
A Demo 23
B Demo 22
C Demo 24
D Demo 25
E Demo 21

@hacky
have an overview at the different options here:

maybe you want to start with exploring the Data column.Expression approach

Hi,

How about using InvokeCode as the following?

Sample20221031-3.zip (2.7 KB)

Regards,

The also described datatable reconstruction approach would look in your case like:

Assign Activity:
dtResult = dtOrig.Clone

Assign Activity:
dtResult =

(From d in dtOrig.AsEnumerable
Let a = d(0).toString.Trim & " Demo"
Let ra = new Object(){a,d(1)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

HI @hacky

Checkout this expression

(From a In DT.AsEnumerable
Let b= a(0).ToString+" Demo"
Let c= a(1).ToString
Select Dt1.Rows.Add(b,c)).CopyToDataTable

Regards
Sudharsan

Hi @hacky

How about this expression

(From d In DtBuild.AsEnumerable()
Let name = d("Name").ToString+" Demo"
Let Age = d("Age")
Let ra = New Object(){name,Age}
Select r = DtClone.Rows.Add(ra)).CopyToDataTable()

Check out this workflow

UpdateDtUsingLINQ.xaml (7.7 KB)

image

Regards
Gokul