1
我在這裏做錯了什麼?Linq Group By Errors
我有以下對象定義:
Public Class MyClass
Public Var1 As String
Public StartDate As Date
Public EndDate As Date
End Class
而在我的主子,我有:
Dim x as New List(Of MyClass)
現在,我希望將有這使得所有羣體都會有信息匹配開始日期和結束日期。我想這應該這樣做:
From Req In x
Group Req By strtdt = Req.StartDate, enddt = Req.EndDate Into grp
Select ...
現在,我已經在幾個不同的方式嘗試這樣做,每次得到不同的錯誤:
1)
From Req In x
Group Req By strtdt = Req.StartDate, enddt = Req.EndDate Into grp
Select ...
錯誤: Definition of method 'grp' is not accessible in this context
(grp()下劃線)
2)
From Req In x
Group Req By New With {strtdt = Req.StartDate, enddt = Req.EndDate} Into grp
Select ...
ERROR:Type or 'With' expected
(第一大括號下劃線)
我在做什麼錯???
謝謝!
@neoetapir - 真棒! - 完美的技巧!謝謝!!! –