Table of Contents

Interface ICdcEventMapper<TEvent>

Namespace
Excalibur.Cdc
Assembly
Excalibur.Cdc.dll

Maps CDC column data to a typed event instance.

public interface ICdcEventMapper<out TEvent>

Type Parameters

TEvent

The target event type.

Examples

internal sealed class OrderCreatedEventMapper : ICdcEventMapper<OrderCreatedEvent>
{
    public OrderCreatedEvent Map(IReadOnlyList<CdcDataChange> changes, CdcChangeType changeType)
    {
        return new OrderCreatedEvent
        {
            OrderId = changes.GetValue<int>("OrderId"),
            CustomerId = changes.GetValue<string>("CustomerId"),
            Total = changes.GetValue<decimal>("Total")
        };
    }
}

Remarks

Implementations should be source-generated or hand-written for AOT safety. Do not use reflection-based property mapping in implementations.

Use with ICdcTableBuilder methods like MapInsert<TEvent, TMapper>() to register a mapper for a specific change type. The mapper is resolved from DI and invoked at runtime when CDC changes are detected.

Methods

Map(IReadOnlyList<CdcDataChange>, CdcChangeType)

Creates a typed event from CDC column changes.

TEvent Map(IReadOnlyList<CdcDataChange> changes, CdcChangeType changeType)

Parameters

changes IReadOnlyList<CdcDataChange>

The column-level changes from the CDC capture.

changeType CdcChangeType

The type of change (Insert, Update, Delete).

Returns

TEvent

A typed event instance populated from the change data.