CepStream.OrderByDescending<TPayload, TOrderKey> Method
Orders the input stream by the rankSelector in descending order.
Namespace: Microsoft.ComplexEventProcessing.Linq
Assembly: Microsoft.ComplexEventProcessing (in Microsoft.ComplexEventProcessing.dll)
Syntax
public static CepOrderedStream<TPayload> OrderByDescending<TPayload, TOrderKey>(
this CepOrderableStream<TPayload> source,
Expression<Func<TPayload, TOrderKey>> rankSelector
)
Type Parameters
- TPayload
Payload type of input events..
- TOrderKey
Type of the ordering key.
Parameters
- source
Type: Microsoft.ComplexEventProcessing.Linq.CepOrderableStream<TPayload>
stream source to order against.
- rankSelector
Type: System.Linq.Expressions.Expression<Func<TPayload, TOrderKey>>
expression whose value is used to compare events against each other.
Return Value
Type: Microsoft.ComplexEventProcessing.Linq.CepOrderedStream<TPayload>
An ordered stream that can further be ranked, for example, by using Take().
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type CepOrderableStream<TPayload>. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=sql.105) or https://msdn.microsoft.com/en-us/library/bb383977(v=sql.105).
Remarks
For more information, see TopK.
Examples
The following example takes the top five events from each snapshot window defined for the input stream inputStream and generates a new event stream. The events in each window are ordered in the ascending order of values in the payload fields e.f combined with the descending order of values in the payload field 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);