Update entire column using Linq

Hi all,

I have a datatable with 87 columns and I want to update the last column.

Based on a dataTable like this


I want something like this


Currently I have a code that obtains the first word from the column “Full Name”, however, I don’t know how to update the last column. The solutions that I’ve found for update, create a new object and put the index columns in order, however, due to the largest number of columns (87), I don’t know how to update it without write manually all the columns index in a new object.

This is my current code.

From row In rawReport

Let name = Split(row.Item("Full Name").ToString(), " ")(0)
Let nr = New Object() {***Idk what to write here***, name }
Select rawReport.Rows.Add(nr)


@ppr (I realized that you are a master for Linq, if you can help that would be great! :slight_smile: )

Welcome to the forum

Updating a single column value we would prefer to do it within a for each row. But for LINQ learning purposes we can do it with the data table reconstruction technique

we assume that the Origin data table has all columns defined and the last column is to update

Assign Activity:
dtResult = dtOrigin.Clone

Assign Activity;
dtResult =

(From d in dtOrigin.AsEnumerable()
Let name = Split(row.Item("Full Name").ToString(), " ")(0)
Let nc = dtOrigin.Columns.Count - 1
Let ra = d.ItemArray.Take(nc).Append(name).toArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable()

Also have a look here:

Thanks a lot! As always, a very good solution :smiley:

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