开发者

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:

  1. Right-click on your project in the solution explorer
  2. Select Properties
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜