我有以下功能:
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() 上出现了问题,说“输入字符串的格式不正确。” 关于为什么的任何想法?这会返回一组行,就像我在其他地方使用相同的代码没有问题一样?