2011-07-17 21 views
1

似乎無擴展團隊在微軟從庫中移除的IEvent接口等,現在的工作,直到最近,下面的代碼不會編譯:如何使用Reactive Extensions無IEvent從OData feed獲取數據?

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 Data Services DataServiceCollection對象的查詢。有什麼想法嗎?

回答

2

只要改變Observable.FromEventObservable.FromEventPattern,你應該重新編譯。

可能要考慮然而只選擇好位:

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