Table of Contents

Class DataChangeExtensions

Namespace
Excalibur.Cdc.SqlServer
Assembly
Excalibur.Cdc.SqlServer.dll

Extension methods for retrieving typed values from data changes in CDC (Change Data Capture) events.

public static class DataChangeExtensions
Inheritance
DataChangeExtensions
Inherited Members

Methods

GetNewValue<T>(DataChangeEvent, string, T)

Retrieves the new value of a specified column from a data change event and converts it to the specified type.

public static T GetNewValue<T>(this DataChangeEvent changeEvent, string columnName, T defaultValue = default)

Parameters

changeEvent DataChangeEvent

The DataChangeEvent containing the changes.

columnName string

The name of the column to retrieve the value from.

defaultValue T

The default value to return if the column is not found or its value is null.

Returns

T

The new value of the column converted to type T, or the defaultValue if the column is not found or its value is null.

Type Parameters

T

The expected type of the column's new value.

GetNewValue<T>(IEnumerable<DataChange>, string, T)

Retrieves the new value of a specified column from a collection of data changes and converts it to the specified type.

public static T GetNewValue<T>(this IEnumerable<DataChange> changes, string columnName, T defaultValue = default)

Parameters

changes IEnumerable<DataChange>

The collection of DataChange objects representing changes in data.

columnName string

The name of the column to retrieve the value from.

defaultValue T

The default value to return if the column is not found or its value is null.

Returns

T

The new value of the column converted to type T, or the defaultValue if the column is not found or its value is null.

Type Parameters

T

The expected type of the column's new value.

Exceptions

InvalidOperationException

Thrown if the column's value is null and the specified type T is not nullable, or if the value cannot be converted to the specified type.

GetOldValue<T>(DataChangeEvent, string, T)

Retrieves the old (previous) value of a specified column from a data change event and converts it to the specified type.

public static T GetOldValue<T>(this DataChangeEvent changeEvent, string columnName, T defaultValue = default)

Parameters

changeEvent DataChangeEvent

The DataChangeEvent containing the changes.

columnName string

The name of the column to retrieve the value from.

defaultValue T

The default value to return if the column is not found or its value is null.

Returns

T

The old value of the column converted to type T, or the defaultValue if the column is not found or its value is null.

Type Parameters

T

The expected type of the column's old value.

GetOldValue<T>(IEnumerable<DataChange>, string, T)

Retrieves the old (previous) value of a specified column from a collection of data changes and converts it to the specified type.

public static T GetOldValue<T>(this IEnumerable<DataChange> changes, string columnName, T defaultValue = default)

Parameters

changes IEnumerable<DataChange>

The collection of DataChange objects representing changes in data.

columnName string

The name of the column to retrieve the value from.

defaultValue T

The default value to return if the column is not found or its value is null.

Returns

T

The old value of the column converted to type T, or the defaultValue if the column is not found or its value is null.

Type Parameters

T

The expected type of the column's old value.

Exceptions

InvalidOperationException

Thrown if the column's value is null and the specified type T is not nullable, or if the value cannot be converted to the specified type.