I have one datatable, in this datatable lot of columns there with values, i need to swap the values between two column. For example, column names are Agent Name and RA Name, need to get the values of RA Name Column and assign to the Agent name column, likewise need to get the values of Agent Name Column and assign to the RA Name Column by using Linq query. I can achive by using for each row activity but its taking so much time to assign the value. So i wants the Linq query for this task.
It would be much simpler just to change the column names.
Assign yourDT.Columns(“Agent Name”).ColumnName = “OLD Agent Name”
Assign yourDT.Columns(“RA Name”).ColumnName = “Agent Name”
Assign yourDT.Columns(“OLD Agent Name”).ColumnName = “RA Name”
If i want to get the value of one column from one datatable and assign to the another datatable column. for example source datatable column name Agent Name and destination column name RA Name. how to use the linq query for this concept? and if i using assign the values to same datatable, column name position is not to change, in this case how can i create the linq query?
Why do you want to use LINQ? It’s totally unnecessary. Just rename the columns.
My condition should not change the columnName position, in this case how to swap the values between two columns?
After renaming the columns, reorder them:
Renaming and reordering will be FAR faster than any For Each or LINQ solution.