现在如何使用响应式扩展而不使用 IEvent 从 OData feed 获取数据?

发布于 2024-11-24 06:03:35 字数 759 浏览 0 评论 0原文

似乎 Microsoft 的 Reactive Extensions 团队从库中删除了 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 对象获取查询结果的最佳方法。有什么想法吗?

Seems the Reactive Extensions team at Microsoft removed the IEvent interface from the library and so now the following code that worked until recently does not compile:

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;
}

I am trying to discover the best way to get the result of a query from a WCF Data Services DataServiceCollection object. Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青衫负雪 2024-12-01 06:03:36

只需将 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);

Just change Observable.FromEvent to Observable.FromEventPattern and you should be compiling again.

You may want to consider selecting just the good bits however:

var eventxs = Observable.FromEvent<LoadCompletedEventArgs>(
                                i => invoices.LoadCompleted += i,
                                 i => invoices.LoadCompleted -= i);
var observable = eventxs.Select(ep => ep.EventArgs.Data);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文