DbProvider Class

Assembly: CodeEffects.Rule.Connection.Postgres.dll
Namespace: CodeEffects.Rule.Connection.Postgres

Summary

The ready-made IDbProvider for PostgreSQL. It connects the Rule Repository and Audit to a PostgreSQL 14 or later database with a connection string and nothing else.

Syntax

public class DbProvider : IDbProvider

Remarks

Create one at startup and share it: every call into the Rule Repository and Audit that touches the database takes it. The provider holds no connection; each unit of work gets a new one from its ConnectionProvider, opens it, and disposes it, so the pooling of Npgsql applies as usual.

Dialect is the PostgreSQL dialect the libraries use to build their statements. A provider of your own, for example one that reads its connection string from a secret store, can return this dialect from its own Dialect property. See Connecting to the Database.

Constructors

  • DbProvider(..)

    public DbProvider(string connectionString, string schemaName = "public")

    Initializes a new instance for the database the connection string names.

    Parameters

    • connectionString (System.String) - The connection string of the database that holds rule storage. Use an account that can only read and write the repository's tables.
    • schemaName (System.String) - The schema that holds the repository's tables. The default is public.

Properties

Example

using CodeEffects.Rule.Connection.Postgres;

var dbProvider = new DbProvider(builder.Configuration.GetConnectionString("Rules"));
builder.Services.AddSingleton<CodeEffects.Rule.Connection.IDbProvider>(dbProvider);

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×