Kindly help as am not good with Linq query. I have a column example as below
Column name -session Id, it has data as below
Now I need to remove this particular string #ADA# from all the rows of this column n then need to copy to data table the entire data table.
Could you pls advise Linq query?
Thanks for your help
Try out this
- Read the data from the source file into a data table using the
Read Range activity.
- Use the
Select method with LINQ to remove the
#ADA# string from all the rows of the
session Id column. Here’s an example LINQ query:
dataTable.AsEnumerable().Select(Function(row) row.Field(Of String)(“session Id”).Replace(“#ADA#”, “”)).CopyToDataTable()
This LINQ query will select all the rows in the data table, remove the
#ADA# string from the
session Id column of each row using the
Replace method, and return the result as a new data table using the
newDataTable = dataTable.AsEnumerable().Select(Function(row) row.Field(Of String)(“session Id”).Replace(“#ADA#”, “”)).CopyToDataTable()
This expression will assign the result of the LINQ query to the
its showing error. could you pls advise.
Give a try with the following
In the invoke code use this
dtInput.AsEnumerable().ToList().ForEach(Sub(r) r("Column name -session Id")= r("Column name -session Id").ToString().Trim().Replace("#ADA#", String.Empty))
Make sure to replace the exact column name within the double quotes
Its sorted with For each data row but if i will have 200000 rows, it will take lot of time.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.