I want to remove GROUP BY clause from the below code. How could i do this.
var newDt = dt.AsEnumerable()
.GroupBy(r => r.Field<string>("BATCH NUM"))
.Select(g =>
{
var row = dt.NewRow();
row["BATCH NUM"] = g.Key;
row["QTY"] = g.Sum(r => Convert.ToInt32(r.Field<string>("QTY")) + Convert.ToInt32(r.Field<string>("BONUS")));
row["PROD ID"] = String.Join(",", g.Select(x => x.Field<string>("PROD ID")).Distinct());
// row["PROD ID"] = g.Select(r => r.Field<string>("PROD ID"));
return row;
}).CopyToDataTable();
It creates problem, when we have two Different "PROD ID" but with same "BATCH NUM"then it combines "PROD ID" into a single field it treats both PROD ID with same batch. Here is a Image you can see
Result which i want is like below.