Linq query to manipulate a string

I have to eliminate .x from any string.
Input - 120.asf.x
12.kiytr.uf90.x
jgui.22980.gtd.x

Required output
120.asf
12.kiytr.uf90
jgui.22980.gtd

Can anyone please help me with a linq query as I have 74k data in excel and using foor loop is very time consuming

Refer this post

Sorry @hasib08 , I need linq query as we are not allowed to use invoke code activity

Refer this post

@hasib08

Tried with dt = dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Replace(“your old value”,” your new value”).ToString).CopyToDatatable()

but here my input column and output column is different

Hi,

Can you try the following expression, for example?

img20220105a7

dt = dt.AsEnumerable().Select(Function(r) dt.Clone.LoadDataRow({r("Column1").ToString.Replace(".x",""),r("Column2")},False)).CopyToDataTable()

Sequence1.xaml (7.0 KB)

Note : We need to modify arguments of LoadDataRow for actual datatable.

Regards,

Hello @Shilpa_Mohanty , I am getting the below error:

Wrong Query it is…

kidnly Post New Topic

LINQ isn’t faster than For Each. LINQ still loops, it’s just hidden from you. It’s impossible for data in a table to be updated without looping.