Skip to main content
Table of Contents

Class ChangeMerger<TBase, TChanges>

Namespace
Stratara.Shared.Merging.ChangeTracking
Assembly
Stratara.Shared.dll

Last-writer-wins change merger for an update operation against the current aggregate state. Compares each property of the incoming TChanges payload against the TBase source the caller saw at command time; when they match, the current aggregate value wins (avoiding lost updates), otherwise the incoming value wins.

public static class ChangeMerger<TBase, TChanges> where TBase : notnull where TChanges : new()

Type Parameters

TBase

CLR type of the aggregate / read model the changes apply to.

TChanges

CLR type of the change-set payload (e.g. an update command).

Inheritance
ChangeMerger<TBase, TChanges>
Inherited Members

Remarks

Property accessors are compiled to delegates and cached per-type-combination for the lifetime of the process. Properties that exist on TChanges but not on TBase are copied through unchanged.

Methods

ApplyChanges(TBase, TBase, TChanges)

Applies changes against the diff of source (caller's view) and current (live aggregate) using last-writer-wins semantics per property.

public static ChangeMergeResult<TChanges> ApplyChanges(TBase source, TBase current, TChanges changes)

Parameters

source TBase

The aggregate / read-model snapshot the caller observed when authoring the change-set.

current TBase

The live aggregate state to merge against.

changes TChanges

The incoming change-set payload (e.g. update command).

Returns

ChangeMergeResult<TChanges>

A ChangeMergeResult<TChanges> with the merged payload and per-property differences.

Exceptions

ArgumentNullException

Thrown when any argument is null.