我对 WCF 相当陌生。我正在尝试使用 linq 或 lambda 作为分页响应从 WCF 服务检索查询,但没有得到它。我的代码如下:
Dim uri As New Uri(My.Settings.Host)
Dim context As New PMXMigrationEntities(uri)
Dim token As DataServiceQueryContinuation(Of APARTMNT) = Nothing
Dim list As New List(Of APARTMNT)
Try
' Execute the query for all apartments and get the response object.'
Dim response As QueryOperationResponse(Of APARTMNT) = _
CType(context.APARTMNTs.Execute(), QueryOperationResponse(Of APARTMNT))
' With a paged response from the service, use a do...while loop '
' to enumerate the results before getting the next link. '
Do
' If nextLink is not null, then there is a new page to load.'
If token IsNot Nothing Then
' Load the new page from the next link URI.'
response = CType(context.Execute(Of APARTMNT)(token), _
QueryOperationResponse(Of APARTMNT))
End If
' Enumerate the apartments in the response.'
For Each a As APARTMNT In response
list.Add(a)
Next
' Get the next link, and continue while there is a next link.'
token = response.GetContinuation()
Loop While token IsNot Nothing
Catch ex As DataServiceQueryException
Throw New ApplicationException( _
"An error occurred during query execution.", ex)
End Try
Return list
我想做类似以下的事情:
CType(context.APARTMNTs.Where(Function(a) a.city.Contains(cityStr)).Execute(), QueryOperationResponse(Of APARTMNT))
和类似的东西:
CType(context.APARTMNTs.Where(Function(a) a.city = cityStr).Execute(), QueryOperationResponse(Of APARTMNT))
现在,我已经读到在这种情况下,linq 或 lambda 被转换为不支持 Contains 函数的 OData 查询,我的替代方案是什么?