我正在从头开始重建我的网站,对数据库进行了重大更改。以下功能在旧网站项目中完美运行,但现在我已将代码复制到新项目中,VS2012不喜欢在托管服务商的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
我在其他功能中也得到了完全相同的行为,任何建议都值得赞赏。
答案 0 :(得分:1)
我猜你有一个全球项目设置级别:
Option Infer Off
在项目设置中检查以确保Option Infer On
,然后在您的单个班级/模块文件中确保没有Option Infer Off