I get all of it working except adding the columns 34-38.
Below the code, bold part is not working:
(From d In dt_390.AsEnumerable
Group d By k = d(“Line No.”).ToString.Trim Into grp = Group
Let cs1 = grp.Sum(Function(rc) Decimal.Parse(“0” & rc(“Receipt Quantity (Available)”).ToString))
Let cs2 = grp.Sum(Function(rc) Decimal.Parse(“0” & rc(“Receipt Amount (Available)”).ToString))
Let ra = grp.First().ItemArray.Take(31).Append(cs1).Append(cs2).Append(grp.First().ItemArray.Skip(33)).ToArray
Select dt_390Cleaned.Rows.Add(ra)).CopyToDataTable
Take(31) is working, appending calculated columns is working, but…
(From d In dt_390.AsEnumerable()
Group d By k = d("Line No.").ToString.Trim() Into grp = Group
Let cs1 = grp.Sum(Function(rc) Decimal.Parse("0" & rc("Receipt Quantity (Available)").ToString))
Let cs2 = grp.Sum(Function(rc) Decimal.Parse("0" & rc("Receipt Amount (Available)").ToString))
Let ra = grp.First().ItemArray.Take(31).Append(cs1).Append(cs2).Concat(grp.First().ItemArray.Skip(33)).ToArray()
Select dt_390Cleaned.Rows.Add(ra)).CopyToDataTable
Let ra1 = grp.First().ItemArray.Take(31)
Let ra2 = new Object(){cs1,cs2}
Let ra = ra1.Concat(ra2).Concat(grp.First().ItemArray.Skip(33)).Cast(Of Object).toArray
Append : The Append method in LINQ is used to add a single element to the end of an existing collection. In the context of arrays, Append can be used to add a single element to the end of an array.
Concat: The Concat method in LINQ is used to concatenate two collections, meaning it combines all the elements of the first collection with all the elements of the second collection. Concat is necessary when you want to join an array (or any collection) with another array (or collection).