Linq for writing in particular rows

Hi Team,

I have a datatable containing,
Invoice number, starting index, ending
abc,2,2
zyz,3,6

So, i want to write in the rows from starting index to ending index, like in a column i want to write success in particular rows. How am i able to do it? I want to do it using LINQ

First create the column using one assign activity,

dt1.Columns.AddRange(New DataColumn() _
{
    New DataColumn("Result", GetType(String)),
})

Then in another Assign Activity,

(From d1 In dt1.AsEnumerable()
Let rowsNeeded = If(Condition_To_Choose_Row,
                                  d1.ItemArray.Take(dt1.Columns.Count -1).Append("Success").ToArray(),
                                  d1.ItemArray.Take(dt1.Columns.Count -1).Append("Failed").ToArray())
Select dt1.Clone().Rows.Add(rowsNeeded)).CopyToDataTable()

Hi @yash.choursia ,

We would suggest you to go ahead with For Each Row in Datatable and using If activity, update the column value as Success or Failure (Or Blank as needed). We use the readily available activities if the operation is a Straight forward updations.

If still required in Linq, We can check with the below Steps :

  1. Assuming you have read the Datatable, say DT.

  2. Next, we need to create a clone of the Input datatable as the Output datatable and add the column to Output datatable using Add Data Column activity for which you want to update it with Success or Failure.
    Cloning :

OutputDT = DT.Clone
  1. Next, use the Below Expression for updating the Result Column, based on the condition :
(From r In DT
Let result = If(r("Column").ToString.Equals("Some Value"),"Success","Failure")
Let ra = r.ItemArray.Append(result).ToArray
Select OutputDT.Rows.Add(ra)).CopyToDatatable

As we do not know the exact condition, an assumption was done.