ShiftEventTime(TPayload) 方法 (CepStream(TPayload), Expression(Func(CepEvent, DateTime)))
將事件的開始時間移位至新的時間戳記,而不變更存留期。
命名空間: Microsoft.ComplexEventProcessing.Linq
組件: Microsoft.ComplexEventProcessing (在 Microsoft.ComplexEventProcessing.dll 中)
語法
public static CepStream<TPayload> ShiftEventTime<TPayload>(
this CepStream<TPayload> source,
Expression<Func<CepEvent, DateTime>> shiftExpr
)
型別參數
- TPayload
輸入事件裝載的類型。
參數
- source
型別:Microsoft.ComplexEventProcessing.Linq. . :: . .CepStream< (Of < ( <'TPayload> ) > ) >
輸入資料流。
- shiftExpr
型別:System.Linq.Expressions. . :: . .Expression< (Of < ( <'Func< (Of < ( <'CepEvent, DateTime> ) > ) >> ) > ) >
定義新開始時間的運算式。
傳回值
型別:Microsoft.ComplexEventProcessing.Linq. . :: . .CepStream< (Of < ( <'TPayload> ) > ) >
包含已移位之事件開始時間的資料流。
使用注意事項
在 Visual Basic 及 C# 中,您可以在任何型別 CepStream< (Of < ( <'TPayload> ) > ) > 的物件上將這個方法做為執行個體方法呼叫。使用執行個體方法語法呼叫這個方法時,請省略第一個參數。如需詳細資訊,請參閱 https://msdn.microsoft.com/zh-tw/library/bb384936(v=sql.105) 或 https://msdn.microsoft.com/zh-tw/library/bb383977(v=sql.105)。
備註
如需詳細資訊,請參閱<時間戳記修改>。
範例
下列範例會將資料流中每一個事件的開始時間移位 15 分鐘到未來。
// shift events by 15 minutes into the future.
var shifted = inputStream.ShiftEventTime(e => e.StartTime + TimeSpan.FromMinutes(15));
下列範例會將資料流中每一個事件的開始時間移位 1 小時到過去。
// shift events by 1 hour into the past.
var shifted = inputStream.ShiftEventTime(e => e.StartTime - TimeSpan.FromHours(1));