我有以下 LINQ 代码,它有语法错误,我不知道如何修复它
Dim query =
From row In mainDatatable.AsEnumerable
'the syntax Error is in the following line
Group row By new { row.Field(Of Double)("cprice") , row.Field(Of Integer)("ccategory")}
Into ProductGroups
'**************************
Dim grpNumber = 1
For Each grp In query
For Each row In grp.ProductGroups
row.SetField("gnum", grpNumber)
Next
grpNumber += 1
Next
End Sub
那我做错了什么?
这是表格的样子,我想按 cprice 和 ccategory 列分组
+---------------+---------------+-----------+------+
| Product Name | cprice | ccategory | gnum |
+---------------+---------------+-----------+------+
| Skirt Red | 99 | 1 | |
| Jeans Blue | 49 | 2 | |
| Jeans Black | 49 | 2 | |
| Skirt Blue | 99 | 1 | |
| T-shirt White | 20 | 2 | |
| T-shirt Green | 20 | 2 | |
| Jeans Grey | 49 | 2 | |
+---------------+---------------+-----------+------+