Skip to content

AgentPrismSqlServerBuilderExtensions

Namespace AgentPrism · Assembly AgentPrism.SqlServer.dll

Extensions that add SQL Server persistence to the AgentPrism chain.

public static class AgentPrismSqlServerBuilderExtensions

objectAgentPrismSqlServerBuilderExtensions

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Enables SQL Server persistence given a connection string.

public static IAgentPrismBuilder UseSqlServer(this IAgentPrismBuilder builder, string connectionString)

builder IAgentPrismBuilder

The AgentPrism chain.

connectionString string

The SQL Server connection string.

IAgentPrismBuilder

The continuation of the chain.

builder.AddAgentPrism()
.UseSqlServer(builder.Configuration.GetConnectionString("AgentPrism")!);

ArgumentNullException

builder is null.

ArgumentException

connectionString is empty.

UseSqlServer(IAgentPrismBuilder, IConfiguration)

Section titled “ UseSqlServer(IAgentPrismBuilder, IConfiguration)”

Enables SQL Server persistence, reading settings from the AgentPrism:SqlServer section.

public static IAgentPrismBuilder UseSqlServer(this IAgentPrismBuilder builder, IConfiguration configurationSection)

builder IAgentPrismBuilder

The AgentPrism chain.

configurationSection IConfiguration

The section settings are read from. Usually configuration.GetSection(AgentPrismSqlServerOptions.SectionName).

IAgentPrismBuilder

The continuation of the chain.

ArgumentNullException

One of the parameters is null.

UseSqlServer(IAgentPrismBuilder, Action<AgentPrismSqlServerOptions>)

Section titled “ UseSqlServer(IAgentPrismBuilder, Action<AgentPrismSqlServerOptions>)”

Enables SQL Server persistence with settings given in code.

public static IAgentPrismBuilder UseSqlServer(this IAgentPrismBuilder builder, Action<AgentPrismSqlServerOptions> configure)

builder IAgentPrismBuilder

The AgentPrism chain.

configure Action<AgentPrismSqlServerOptions>

The settings mutator.

IAgentPrismBuilder

The continuation of the chain.

Stores are registered with ServiceCollectionDescriptorExtensions.Replace, not TryAdd. AddAgentPrism has already registered the in-memory stores with TryAddSingleton and runs before this call in the chain; using TryAdd here would silently do nothing.

Overwriting is correct here because UseSqlServer is the consumer’s explicit choice. The “register with TryAdd” rule is for AgentPrism’s defaults, not for explicit calls.

ArgumentNullException

One of the parameters is null.