OrderByDescending(TPayload, TOrderKey) 方法

依 rankSelector 以遞減順序排序輸入資料流。

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

語法

public static CepOrderedStream<TPayload> OrderByDescending<TPayload, TOrderKey>(
    this CepOrderableStream<TPayload> source,
    Expression<Func<TPayload, TOrderKey>> rankSelector
)

型別參數

  • TPayload
    輸入事件的裝載類型。
  • TOrderKey
    排序索引鍵的類型。

參數

傳回值

型別:Microsoft.ComplexEventProcessing.Linq. . :: . .CepOrderedStream< (Of < ( <'TPayload> ) > ) >
可以進一步排名的已排序資料流,例如,使用 Take()。

使用注意事項

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

備註

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

範例

下列範例會從針對輸入資料流 inputStream 所定義的每個快照集視窗中取得前五個事件並產生新的事件資料流。每一個視窗中的事件都會依照裝載欄位 e.f 中值的遞增順序並結合裝載欄位 e.i 中值的遞減順序來排序。

// Assuming the following input event type for inputStream: 
public class MyPayload 
{
  public int f; 
  public int i; 
}

var topfive = (from window in inputStream.Snapshot(SnapshotWindowOutputPolicy.Clip)
               from e in window
               orderby e.f ascending, e.i descending
               select e).Take(5);

請參閱

參考

CepStream 類別

Microsoft.ComplexEventProcessing.Linq 命名空間