Reference

UseInMemory

Package Trax.Effect.Data.InMemoryNamespaces Trax.Effect.Data.InMemory.Extensions, Trax.Effect.Data.InMemory.Services.InMemoryContextFactorySource ServiceExtensions.cs, InMemoryContexFactory.cs

The in-memory data provider. Keeps the trax tables in an EF Core in-memory database that lives as long as the process: nothing to run, nothing kept after the host stops.

Signature

public static TraxEffectBuilderWithData UseInMemory(
    this TraxEffectBuilder configurationBuilder
)

Returns

TraxEffectBuilderWithData, which carries the methods that need a data provider. See AddEffects.

Behavior

Each call creates one InMemoryDatabaseRoot, and every context the provider creates, through the factory or the scoped IDataContext, shares it, so they all see the same data. It sets HasDataProvider but not HasDatabaseProvider: the scheduler then runs its in-memory set of services and skips the startup work that needs a database, and no ISqlDialect or IQueuedWorkListener is registered. NUL characters are stored unchanged.

Registered services

ServiceLifetimeRole
IDataContextProviderFactorySingletonAn InMemoryContextProviderFactory over the shared root, registered as a non-toggleable effect
IDataContextScopedA context over the shared root
ICheckpointRowsSingleton, if none is registeredThe rows checkpoints are stored in
ITraxFeatureDbConfiguratorSingletonA DelegateFeatureDbConfigurator that points a feature's own DbContext at the same in-memory store

InMemoryContextProviderFactory

public class InMemoryContextProviderFactory(InMemoryDatabaseRoot databaseRoot) : IDataContextProviderFactory
MemberDescription
Create()A new context over databaseRoot
CreateDbContextAsync(cancellationToken)The same, as a task

Transactions are accepted and ignored, as the EF Core in-memory provider does.

Example

services.AddTrax(trax => trax
    .AddEffects(effects => effects
        .UseInMemory()
    )
    .AddMediator(typeof(IShipOrderTrain).Assembly)
);

See also