Skip to content

AgentPrismPostgreSqlBuilderExtensions

Namespace AgentPrism · Assembly AgentPrism.PostgreSql.dll

Extensions that add PostgreSQL persistence to the AgentPrism chain.

public static class AgentPrismPostgreSqlBuilderExtensions

objectAgentPrismPostgreSqlBuilderExtensions

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

UsePostgreSql(IAgentPrismBuilder, string)

Section titled “ UsePostgreSql(IAgentPrismBuilder, string)”

Enables PostgreSQL persistence given a connection string.

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

builder IAgentPrismBuilder

The AgentPrism chain.

connectionString string

The PostgreSQL connection string.

IAgentPrismBuilder

The continuation of the chain.

The schema is created and migrated at startup; no separate migration step is needed.

builder.AddAgentPrism()
.UseOpenAI(builder.Configuration["OpenAI:ApiKey"]!)
.UsePostgreSql(builder.Configuration.GetConnectionString("AgentPrism")!);

ArgumentNullException

builder is null.

ArgumentException

connectionString is empty.

UsePostgreSql(IAgentPrismBuilder, IConfiguration)

Section titled “ UsePostgreSql(IAgentPrismBuilder, IConfiguration)”

Enables PostgreSQL persistence, reading settings from the AgentPrism:PostgreSql section.

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

builder IAgentPrismBuilder

The AgentPrism chain.

configurationSection IConfiguration

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

IAgentPrismBuilder

The continuation of the chain.

ArgumentNullException

One of the parameters is null.

UsePostgreSql(IAgentPrismBuilder, Action<AgentPrismPostgreSqlOptions>)

Section titled “ UsePostgreSql(IAgentPrismBuilder, Action<AgentPrismPostgreSqlOptions>)”

Enables PostgreSQL persistence with settings given in code.

public static IAgentPrismBuilder UsePostgreSql(this IAgentPrismBuilder builder, Action<AgentPrismPostgreSqlOptions> configure)

builder IAgentPrismBuilder

The AgentPrism chain.

configure Action<AgentPrismPostgreSqlOptions>

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 UsePostgreSql 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.