LINQ VB.NET variable not found when looping through grouped query
I'm trying to do the following LINQ grouping, which works in the debugger (the results are populated in the GroupedOrders object. But VS 2008 gives me the following error at design time...
Name 'x' is not declared
Dim GroupedOrders = (From m In thisConsultant.orders _
Group m By Key = m.commCode Into Group _
Select commCode = Key, orders = Group)
For Each x In GroupedOrders
Next
Public Structure consultantDetail
Public orders As List(Of orderDetail)
End Structure
Public Structure orderDetail
Public transactionID As Integer
Public qualifyingVolume As Decimal
Public commissionableVolume As Decimal
Public sponsorID As Integer
Public orderDate As DateTime
Public commCode As String
开发者_StackOverflow中文版Public commPercentage As Decimal
Public discountPercent As Decimal
End Structure
Do you have Option Infer On
?
My guess is that you have Option Strict On
and Option Infer Off
. To check these settings:
- Right-click on your project in the solution explorer
- Select Properties
- Select the Compile tab on the left
try to surround the Linq query with try-catch. Sometimes, there are error that are not catch directly by VS2008.
精彩评论