.net - 如何使用URL查询处理WCF-OData中的延续?

标签 .net wcf odata

我正在使用指向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);

但是,我看不到如何为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
});

如何使用基于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());

简而言之,Execute方法返回QueryOperationResponse的实例,该实例实现IEnumerable但也公开了延续。

关于.net - 如何使用URL查询处理WCF-OData中的延续?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5515829/

相关文章:

c# - 温莎城堡拦截机

c# - 迁移 "Legacy"SQLite 数据库以使用 Entity Framework 时的主键问题

android - 从 Android 将 JSONArray 发布到 WCF 服务

c# - OData - 将字段添加到代理部分类但需要在请求中忽略它们

c# - 如何验证在最小起订量中未调用该方法?

c# - 如何自定义 Windows 窗体的系统菜单?

WCF 和带模板的数据协定

javascript - Angular JS 应用程序 POST.Success 不是 Wcf REST 服务的功能

c# - 使用 Asp.Net WebApi + EF + Odata 深度插入数据

asp.net-web-api - 如何从 System.Web.Http.ModelBinding.IModelBinder 传递结果模型对象。绑定(bind)模型?