现在如何使用无IEvent的响应式扩展从OData feed中获取数据



似乎微软的响应式扩展团队从库中删除了IEvent接口,所以现在下面的代码直到最近还在工作,不能编译:

using ODataServiceReference;
public static IObservable<IEvent<LoadCompletedEventArgs>> GetInvoices(Uri uri)
{
    var context = new ODataEntities(uri);
    var invoices = new DataServiceCollection<ODataEntities.Invoice>(context);
    var observable = Observable.FromEvent<LoadCompletedEventArgs>(
                                i => invoices.LoadCompleted += i,
                                 i => invoices.LoadCompleted -= i);
    var query = from i in context.Invoices
        select i;
    invoices.LoadAsync(query);
    return observable;
}

我正试图发现从WCF数据服务DataServiceCollection对象获取查询结果的最佳方法。任何想法吗?

只需将Observable.FromEvent更改为Observable.FromEventPattern,就可以重新编译了。

可能想要考虑只选择好的部分:

var eventxs = Observable.FromEvent<LoadCompletedEventArgs>(
                                i => invoices.LoadCompleted += i,
                                 i => invoices.LoadCompleted -= i);
var observable = eventxs.Select(ep => ep.EventArgs.Data);

相关内容

  • 没有找到相关文章

最新更新