Table of Contents

Interface ICdcTableBuilder

Namespace
Excalibur.Cdc
Assembly
Excalibur.Cdc.dll

Fluent builder interface for configuring CDC table tracking settings.

public interface ICdcTableBuilder

Examples

cdc.TrackTable("dbo.Orders", table =>
{
    table.MapInsert<OrderCreatedEvent>()
         .MapUpdate<OrderUpdatedEvent>()
         .MapDelete<OrderDeletedEvent>()
         .WithFilter(change => change.NewValue != null)
         .CaptureInstance("dbo_Orders_CT");
});

Remarks

This builder configures how changes to a specific database table are tracked and mapped to domain events. It supports mapping different operations (INSERT, UPDATE, DELETE) to different event types.

All methods return this for method chaining.

Methods

CaptureInstance(string)

Sets the CDC capture instance name (SQL Server specific).

ICdcTableBuilder CaptureInstance(string name)

Parameters

name string

The capture instance name.

Returns

ICdcTableBuilder

The builder for fluent chaining.

Examples

table.CaptureInstance("dbo_Orders_Audit");

Remarks

By default, SQL Server CDC uses the capture instance name format schema_table. Use this method to override the default name.

Exceptions

ArgumentException

Thrown when name is null or whitespace.

MapAll<TEvent>()

Maps ALL operations (INSERT, UPDATE, DELETE) to a single event type.

ICdcTableBuilder MapAll<TEvent>() where TEvent : class

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for all operations.

Examples

table.MapAll<OrderChangedEvent>();

Remarks

This is a convenience method that registers the same event type for all change operations. Use this when you want a unified event that captures any change to the table.

MapAll<TEvent, TMapper>()

Maps ALL operations (INSERT, UPDATE, DELETE) to a single event type with an explicit mapper.

ICdcTableBuilder MapAll<TEvent, TMapper>() where TEvent : class where TMapper : class, ICdcEventMapper<TEvent>

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for all operations.

TMapper

The mapper type that creates event instances from change data.

MapDelete<TEvent>()

Maps DELETE operations to an event type.

ICdcTableBuilder MapDelete<TEvent>() where TEvent : class

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for DELETE operations.

Examples

table.MapDelete<OrderDeletedEvent>();

Remarks

When a row is deleted from the tracked table, an instance of TEvent will be created with the deleted row data.

MapDelete<TEvent, TMapper>()

Maps DELETE operations to an event type with an explicit mapper.

ICdcTableBuilder MapDelete<TEvent, TMapper>() where TEvent : class where TMapper : class, ICdcEventMapper<TEvent>

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for DELETE operations.

TMapper

The mapper type that creates event instances from change data.

MapInsert<TEvent>()

Maps INSERT operations to an event type.

ICdcTableBuilder MapInsert<TEvent>() where TEvent : class

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for INSERT operations.

Examples

table.MapInsert<OrderCreatedEvent>();

Remarks

When a new row is inserted into the tracked table, an instance of TEvent will be created with the new row data.

MapInsert<TEvent, TMapper>()

Maps INSERT operations to an event type with an explicit mapper.

ICdcTableBuilder MapInsert<TEvent, TMapper>() where TEvent : class where TMapper : class, ICdcEventMapper<TEvent>

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for INSERT operations.

TMapper

The mapper type that creates event instances from change data.

Remarks

The mapper is resolved from DI and invoked at runtime to create typed event instances. This overload enables auto-mapping without manual IDataChangeHandler implementation.

MapUpdate<TEvent>()

Maps UPDATE operations to an event type.

ICdcTableBuilder MapUpdate<TEvent>() where TEvent : class

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for UPDATE operations.

Examples

table.MapUpdate<OrderUpdatedEvent>();

Remarks

When an existing row is updated in the tracked table, an instance of TEvent will be created with both old and new row data.

MapUpdate<TEvent, TMapper>()

Maps UPDATE operations to an event type with an explicit mapper.

ICdcTableBuilder MapUpdate<TEvent, TMapper>() where TEvent : class where TMapper : class, ICdcEventMapper<TEvent>

Returns

ICdcTableBuilder

The builder for fluent chaining.

Type Parameters

TEvent

The event type to create for UPDATE operations.

TMapper

The mapper type that creates event instances from change data.

WithFilter(Func<CdcDataChange, bool>)

Configures a filter predicate for change events.

ICdcTableBuilder WithFilter(Func<CdcDataChange, bool> predicate)

Parameters

predicate Func<CdcDataChange, bool>

The predicate to filter changes.

Returns

ICdcTableBuilder

The builder for fluent chaining.

Examples

table.WithFilter(change => change.ColumnName != "UpdatedAt");

Remarks

Only changes that match the filter predicate will be processed. This allows filtering changes at the CDC level before events are created.

Exceptions

ArgumentNullException

Thrown when predicate is null.