Table of Contents

Class CdcPosition

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

Represents the current position in the CDC log for a specific table, defined by a Log Sequence Number (LSN) and an optional sequence value.

public sealed class CdcPosition : IEquatable<CdcPosition>
Inheritance
CdcPosition
Implements
Inherited Members

Remarks

This type bridges the SQL Server-specific LSN/SeqVal position representation with the unified ChangePosition abstraction via ToChangePosition() and FromChangePosition(ChangePosition?). This follows the same adapter pattern used by PostgresCdcPosition and MongoDbCdcPosition.

SQL Server CDC positions consist of a 10-byte Log Sequence Number and an optional sequence value for sub-LSN ordering within the same transaction.

Constructors

CdcPosition(byte[], byte[]?)

Represents the current position in the CDC log for a specific table, defined by a Log Sequence Number (LSN) and an optional sequence value.

public CdcPosition(byte[] lsn, byte[]? seqVal)

Parameters

lsn byte[]
seqVal byte[]

Remarks

This type bridges the SQL Server-specific LSN/SeqVal position representation with the unified ChangePosition abstraction via ToChangePosition() and FromChangePosition(ChangePosition?). This follows the same adapter pattern used by PostgresCdcPosition and MongoDbCdcPosition.

SQL Server CDC positions consist of a 10-byte Log Sequence Number and an optional sequence value for sub-LSN ordering within the same transaction.

Properties

IsValid

Gets a value indicating whether this position is valid (has a non-empty LSN).

public bool IsValid { get; }

Property Value

bool

Lsn

Gets the Log Sequence Number indicating the current CDC position.

public byte[] Lsn { get; init; }

Property Value

byte[]

The Log Sequence Number indicating the current CDC position.

SequenceValue

Gets an optional sequence value for finer-grained CDC tracking.

public byte[]? SequenceValue { get; init; }

Property Value

byte[]

An optional sequence value for finer-grained CDC tracking.

Methods

Equals(CdcPosition?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CdcPosition? other)

Parameters

other CdcPosition

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromChangePosition(ChangePosition?)

Creates a CdcPosition from a ChangePosition.

public static CdcPosition FromChangePosition(ChangePosition? position)

Parameters

position ChangePosition

The change position to convert.

Returns

CdcPosition

A CdcPosition parsed from the token, or a position with an empty LSN if the input is null, invalid, or cannot be parsed.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ToChangePosition()

Converts this position to a ChangePosition for use with the unified ISqlServerCdcStateStore contract.

public ChangePosition ToChangePosition()

Returns

ChangePosition

A TokenChangePosition with the LSN encoded as a hex string, optionally including the sequence value separated by a pipe character.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.