Share via


CepStream.AlterEventLifetime<TPayload> Method

Alters the lifetime of the events in the stream. This method can change both the start time and end time of an event.

Namespace:  Microsoft.ComplexEventProcessing.Linq
Assembly:  Microsoft.ComplexEventProcessing (in Microsoft.ComplexEventProcessing.dll)

Syntax

public static CepStream<TPayload> AlterEventLifetime<TPayload>(
    this CepStream<TPayload> source,
    Expression<Func<CepEvent, DateTime>> startTimeFunc,
    Expression<Func<CepEvent<TPayload>, TimeSpan>> lifeTimeFunc
)

Type Parameters

  • TPayload
    The type of the input event payload.

Parameters

Return Value

Type: Microsoft.ComplexEventProcessing.Linq.CepStream<TPayload>
A new stream with changed event lifetimes.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type CepStream<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, Time Stamp Modifications.

Examples

The following example shifts the event time 1 minute into the past, but leaves the end time of the event unchanged (by adding an additional minute to the original lifetime) when specifying the new lifetime as the second parameter.

// shift event 1 minute into the past, but leave the end time (event duration) unchanged.
var newStream = inputStream.AlterEventLifetime(e => e.StartTime - TimeSpan.FromMinutes(1),
                                               e => e.EndTime - e.StartTime + TimeSpan.FromMinutes(1));

See Also

Reference

CepStream Class

Microsoft.ComplexEventProcessing.Linq Namespace