Share via


Join(TOuter, TInner, TKey, TResult) 方法

在給定的聯結索引鍵上,將外部資料流的事件與內部資料流的事件聯結在一起。

命名空間:  Microsoft.ComplexEventProcessing.Linq
組件:  Microsoft.ComplexEventProcessing (在 Microsoft.ComplexEventProcessing.dll 中)

語法

public static CepStream<TResult> Join<TOuter, TInner, TKey, TResult>(
    this CepStream<TOuter> outer,
    CepStream<TInner> inner,
    Expression<Func<TOuter, TKey>> outerKeySelector,
    Expression<Func<TInner, TKey>> innerKeySelector,
    Expression<Func<TOuter, TInner, TResult>> selector
)

型別參數

  • TOuter
    外部資料流的事件類型。
  • TInner
    內部資料流的事件類型。
  • TKey
    聯結索引鍵類型。
  • TResult
    聯結結果類型。

參數

傳回值

型別:Microsoft.ComplexEventProcessing.Linq. . :: . .CepStream< (Of < ( <'TResult> ) > ) >
已聯結之事件的資料流。

使用注意事項

在 Visual Basic 及 C# 中,您可以在任何型別 CepStream< (Of < ( <'TOuter> ) > ) > 的物件上將這個方法做為執行個體方法呼叫。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=sql.105)https://msdn.microsoft.com/zh-tw/library/bb383977(v=sql.105)

備註

如需詳細資訊,請參閱<聯結>。

範例

下列範例會比較 stream1 資料流中的事件與 stream2 資料流中的事件。資料流中符合 on 子句所定義之相等準則的事件 (也會在兩個事件的時間間隔內重疊) 會聯結並輸出至新的事件,而這個新事件包含 e1 事件中的 i 和 j 裝載欄位以及 e2 事件中的 j 欄位。

// Assuming the following input event type for both stream1 and stream2.
public class MyPayload
{
    public int i;
    public float j;
}

var equiJoin = from e1 in stream1
               join e2 in stream2
               on e1.i equals e2.i
               select new { e1.i, e1.j, e2.j };

請參閱

參考

CepStream 類別

Microsoft.ComplexEventProcessing.Linq 命名空間