Linq Query to split value in a cell

Hello Everyone,

Please share a linq query to split cell value in a column. Please refer to the below image

Input:
image

Required:
image

for each row in datable
row(“column1”)= row(“column1”).split("-"c)(0).tostring

need linq query please and i know how to do with for each

Thank you

with the reference to your previous question:

give a try at following:

Assign Activity
dtResult = dtOrig.Clone

Assingn Activity:
dtResult =

(From d in dtOrig.AsEnumerable
Group d by k=d("Column1").toString.Trim.Split("-"c).First() into grp=Group
Let sm = grp.Sum(Function (x) CInt(x("Column2").toString))
Let ra = new Object(){k,sm}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
1 Like

Thank you for quick response it working

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