1

我正在从头开始重建我的网站,并对数据库进行了重大更改。以下函数在旧网站项目中运行良好,但现在我已经将代码复制到新项目中,VS2012 不喜欢 custorders 中的 For Each 订单中的“订单”,说订单未声明并且可能不会由于其保护级别而可访问

Public Shared Function GetOrderDisplaybyCustomerId(ByVal customerId As Integer) As List(Of OrderDisplay)
    Dim list As New List(Of OrderDisplay)
    Dim item As New OrderDisplay
    Using ctx As New webEntities
        Dim custorders = (From o In ctx.salesorders
                         Where o.order_divisionId = customerId
                         Join s In ctx.addresses On o.order_shippingAddressId Equals s.addressId
                         Join st In ctx.states On s.address_stateProvinceId Equals st.stateId
                         Order By o.OrderDate Ascending
                         Select New With {o.OrderDate, o.InvoiceNumber, o.CustomerPONumber, o.AccountNumber, s.StreetAddress, s.City, st.AbbreviatedName}).ToList()
        If custorders.Count > 0 Then
            For Each order In custorders
                item._orderdate = order.OrderDate.ToShortDateString()
                item._invoicenumber = order.InvoiceNumber
                item._customerPOnumber = order.CustomerPONumber
                item._acctnumber = order.AccountNumber
                item.Address = order.StreetAddress
                item.City = order.City
                item.State = order.AbbreviatedName
                list.Add(item)
            Next
            Return list
        Else
            Return Nothing
        End If
    End Using
End Function

我在其他功能中也得到了完全相同的行为,任何建议表示赞赏。

4

1 回答 1

1

我猜你有一个全球项目级别的设置:

Option Infer Off

在您的项目设置中检查它以确保Option Infer On,然后在您的个人类/模块文件中,确保没有Option Infer Off

于 2013-09-05T07:49:16.680 回答