(From row In dtInput.AsEnumerable()
Group row By ModelPrefix = If(row(“Model”).ToString().Length >= 4, row(“Model”).ToString().Substring(0, 4), row(“Model”).ToString()) Into Group
Let GroupedFiyat = String.Join(“,”, Group.Select(Function(r) r(“Fiyat”).ToString()))
Select dtOutput.Rows.Add({ModelPrefix,GroupedFiyat})).CopyToDataTable()
The above code goes through each row in the datatable and group based on first 4 letters in the string if the length of value in Model is 4 or more, else it takes the string as it is.
We assign a variable ModelPrefix that stores the substring used to group the value
Using Let we assign another variable GroupedFiyat that stores the list of values grouped. We convert the list to a string by joinning it based on comma.
Using Select we add Rows to the output datatable to columns Model and Fiyat