Class EventValueMapBuilder<TUpgrade, TPrevious>

Namespace
Cratis.Chronicle.Events.Migrations
Assembly
Cratis.Chronicle.dll

Represents an implementation of IEventValueMapBuilder<TUpgrade, TPrevious>.

public class EventValueMapBuilder<TUpgrade, TPrevious> : IEventValueMapBuilder<TUpgrade, TPrevious>

Type Parameters

TUpgrade

The upgraded (newer generation) event type.

TPrevious

The previous (older generation) event type.

Inheritance
EventValueMapBuilder<TUpgrade, TPrevious>
Implements
IEventValueMapBuilder<TUpgrade, TPrevious>
Inherited Members
Extension Methods

Constructors

EventValueMapBuilder()

public EventValueMapBuilder()

Properties

HasMaps

Gets whether any value map has been declared.

public bool HasMaps { get; }

Property Value

bool

Methods

ApplyDowncast(IEventMigrationPropertyBuilder)

Apply every declared map to the downcast of the migration, translating upgraded values back into previous ones.

public void ApplyDowncast(IEventMigrationPropertyBuilder builder)

Parameters

builder IEventMigrationPropertyBuilder

The IEventMigrationPropertyBuilder to apply to.

ApplyUpcast(IEventMigrationPropertyBuilder)

Apply every declared map to the upcast of the migration, translating previous values into upgraded ones.

public void ApplyUpcast(IEventMigrationPropertyBuilder builder)

Parameters

builder IEventMigrationPropertyBuilder

The IEventMigrationPropertyBuilder to apply to.

For<TUpgradeProperty, TPreviousProperty>(Expression<Func<TUpgrade, TUpgradeProperty>>, Expression<Func<TPrevious, TPreviousProperty>>, Action<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>>)

Declare the value map for a property, from how the previous generation expressed it to how the upgraded generation does.

public IEventValueMapBuilder<TUpgrade, TPrevious> For<TUpgradeProperty, TPreviousProperty>(Expression<Func<TUpgrade, TUpgradeProperty>> upgradeProperty, Expression<Func<TPrevious, TPreviousProperty>> previousProperty, Action<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>> map)

Parameters

upgradeProperty Expression<Func<TUpgrade, TUpgradeProperty>>

Expression selecting the property on the upgraded generation.

previousProperty Expression<Func<TPrevious, TPreviousProperty>>

Expression selecting the property on the previous generation.

map Action<IValueMapBuilder<TPreviousProperty, TUpgradeProperty>>

Action declaring which value becomes which.

Returns

IEventValueMapBuilder<TUpgrade, TPrevious>

The builder for continued configuration.

Type Parameters

TUpgradeProperty

The type of the property on the upgraded generation.

TPreviousProperty

The type of the property on the previous generation.

Remarks

The two properties do not have to share a name - the map carries the value across from one to the other, so it also covers a rename of the property it maps.