Convert For Each to LINQ - Trim Datatable Header

Hello,

The datatable header have trailing spaces and I would like to clean it up. I have this for each but wonder if we can convert it to LINQ?
image
Assign:
DT.Columns(i).ColumnName = DT.Columns(i).ColumnName.Trim

we would recommend to stay with this or similiar approch like:

  • for each iteration over the datacolumns (direct / dtVar.Clone().Columns) | TypeArgument: DataColumn
  • Repeat number of times activity

A LINQ has the risk to result in more code length or Blackboxing by invoke code activity

1 Like

Hi,

Can you try the following code in InvokeCode activity?

Dim dtIn as DataTable = dt
Enumerable.Range(0,dtIn.Columns.Count).ToList.ForEach(Sub(i)
    dtIn.Columns(i).ColumnName=dtIn.Columns(i).ColumnName.Trim
End Sub
)

Sequence.xaml (7.3 KB)

Regards,

1 Like

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