私は次の機能を持っています:
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()で、「入力文字列が正しい形式ではありませんでした」と言ってバグアウトしています。理由について何か考えはありますか?これは、同じコードを他の場所で問題なく使用しているのと同じように、行のコレクションを返しますか?