我正在使用指向OData端点的WCF数据服务.如果我使用DataServiceQuery,我可以毫无困难地管理延续.
var collection = new DataServiceCollection<T>();
collection.LoadCompleted += (sender, e) =>
{
if (e.Error != null)
{
callback(null, e.Error);
return;
}
var thisCollection = (DataServiceCollection<T>) sender;
if (thisCollection.Continuation != null)
{
thisCollection.LoadNextPartialSetAsync();
}
else
{
var items = thisCollection.ToList();
callback(items, e.Error);
}
};
collection.LoadAsync(query);
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何为DataServiceContext.BeginExecute(string url,...)方法执行相同操作.
_odataContext.BeginExecute<T>(new Uri(requestUrl), x =>
{
var items = _odataContext.EndExecute<T>(x);
//not sure how to get the rest of the items with this method
});
Run Code Online (Sandbox Code Playgroud)
如何使用基于URL的查询方法,但仍然可以获得持续支持?
同步示例(为了更简单):
var r = ctx.Execute<Product>(new Uri("http://services.odata.org/Northwind/Northwind.svc/Products"));
QueryOperationResponse<Product> response = (QueryOperationResponse<Product>)r;
response.Count();
Console.WriteLine(response.GetContinuation());
Run Code Online (Sandbox Code Playgroud)
简而言之,Execute 方法返回 QueryOperationResponse 的实例,该实例实现 IEnumerable 但也公开了延续。
归档时间: |
|
查看次数: |
2246 次 |
最近记录: |