我正在尝试从Odata源中检索整个数据列表,但我似乎无法使我的getContinuation工作......到目前为止我的代码如下:
var nwd = new OdataServiceReference.NorthwindEntities(new Uri("http://services.odata.org/Northwind/Northwind.svc/"));
var res1 = nwd.Orders //response
.OrderBy(o => o.OrderID)
.Select(o => new
{
o.OrderID,
o.Customer.CompanyName,
o.Customer.ContactName,
o.Employee.FirstName,
o.Employee.LastName,
o.Order_Details
}) as DataServiceQuery;
var response = (QueryOperationResponse<Order>)
nwd.Execute<Order>(new Uri(res1.ToString()));
//var response = res1.Execute() as QueryOperationResponse<OdataServiceReference.Order>;
var res1List = new List<Order>(response);
DataServiceQueryContinuation<Order> token;
while ((token = response.GetContinuation()) != null)
{
response = nwd.Execute<Order>(token) as QueryOperationResponse<Order>;
res1List.AddRange(response);
}
我收到以下错误:
任何帮助都会很棒!
答案 0 :(得分:0)
尝试将Order
替换为OdataServiceReference.Order
,例如将Execute<Order>
替换为Execute<OdataServiceReference.Order>
,依此类推,看看是否有帮助。