我有以下功能:使用任何()返回錯誤VB.NET
Public Function CheckHasRoom(people_id As String, semester As String, year As String)
' Don't let folks already registered for a room register for another.
Dim RoomSelected As String
Using dbContext As pbu_housingEntities = New pbu_housingEntities
Dim hasroom = (From p In dbContext.Residents _
Where p.people_code_id = people_id _
Where p.semester = semester _
Where p.year = year _
Where (p.room = "" _
Or p.building Is Nothing) _
Select p)
If hasroom.Any() Then
' Let them keep going.
RoomSelected = "N"
Else
' Redirect them to the main page.
RoomSelected = "Y"
' HttpContext.Current.Response.Redirect("default.aspx")
End If
End Using
Return RoomSelected
End Function
但它在hasroom.Any()竊聽出來說:「輸入字符串的不正確格式。」任何想法爲什麼?這是返回的行集合,就像我在其他地方使用相同的代碼而沒有問題?
您是否考慮過逐步測試Linq查詢?每次在每行添加一行,看看是否有錯誤。 – JurgenStillaert 2012-04-12 14:49:30