Class CdcDataChangeExtensions
Extension methods for extracting typed values from CDC change data.
public static class CdcDataChangeExtensions
- Inheritance
-
CdcDataChangeExtensions
- Inherited Members
Remarks
These methods are designed for use in ICdcEventMapper<TEvent> implementations to extract column values from change data without reflection.
Methods
GetOldValue<T>(IReadOnlyList<CdcDataChange>, string)
Gets the old value (before change) of a column by name, cast to T.
public static T GetOldValue<T>(this IReadOnlyList<CdcDataChange> changes, string columnName)
Parameters
changesIReadOnlyList<CdcDataChange>The list of column changes.
columnNamestringThe column name to look up.
Returns
- T
The old value of the column cast to
T.
Type Parameters
TThe expected type of the column value.
Exceptions
- CdcMappingException
Thrown when the column is not found in the change data.
GetValue<T>(IReadOnlyList<CdcDataChange>, string)
Gets the new value of a column by name, cast to T.
public static T GetValue<T>(this IReadOnlyList<CdcDataChange> changes, string columnName)
Parameters
changesIReadOnlyList<CdcDataChange>The list of column changes.
columnNamestringThe column name to look up.
Returns
- T
The new value of the column cast to
T.
Type Parameters
TThe expected type of the column value.
Exceptions
- CdcMappingException
Thrown when the column is not found in the change data.
TryGetValue<T>(IReadOnlyList<CdcDataChange>, string, out T?)
Tries to get the new value of a column; returns false if the column is missing.
public static bool TryGetValue<T>(this IReadOnlyList<CdcDataChange> changes, string columnName, out T? value)
Parameters
changesIReadOnlyList<CdcDataChange>The list of column changes.
columnNamestringThe column name to look up.
valueTWhen this method returns, contains the column value if found; otherwise, the default value.
Returns
Type Parameters
TThe expected type of the column value.