Public Shared Function GetLocationId(ByVal LocCode As String) As Integer
Dim LocationId As Integer = 0
Using dc1 As New Reviews.ReviewsDataClassesDataContext()
Dim LocQuery = (From qryItem In dc1.Locations Where qryItem.LocationCode = LocCode Select qryItem).FirstOrDefault()
If Not LocQuery Is Nothing Then
LocationId = LocQuery.Id
End If
End Using
Return LocationId
End Function
我通过函数传递CPAH作为LocCode。我在Locations表中的locationCode列下有CPAH,但此查询仍然没有返回任何内容。我究竟做错了什么? '