Below is the correct one-line LINQ expression to use in an Assign activity in UiPath:
dt_Result = (From r In dt_Input.AsEnumerable() Group r By k = r(“くだもの”).ToString() Into g = Group Select dt_Result.LoadDataRow({k, g.Sum(Function(x) CInt(x(“個数”)))}, False)).CopyToDataTable()
Okay So first, create and initialize the result DataTable before the Assign in a separate Assign or Build Data Table
dt_Result = dt_Input.Clone() in assign activity
then use the below one-liner linq
dt_Result = (From r In dt_Input.AsEnumerable() Group r By k = r(“くだもの”).ToString() Into g = Group Select dt_Result.LoadDataRow({k, g.Sum(Function(x) CInt(x(“個数”)))}, False)).CopyToDataTable()
If the error still appears, the most stable alternative is to avoid LoadDataRow inside LINQ entirely and project to an anonymous object first
dt_Result = (From r In dt_Input.AsEnumerable() Group r By k = r(“くだもの”).ToString() Into g = Group Select New Object() {k, g.Sum(Function(x) CInt(x(“個数”)))}).CopyToDataTable()