DbProvider Class
Assembly: CodeEffects.Rule.Connection.SqlServer.dll
Namespace: CodeEffects.Rule.Connection.SqlServer
Summary
The ready-made IDbProvider for SQL Server. It connects the Rule Repository and Audit to a SQL Server 2012 or later database with a connection string and nothing else.
Syntax
public class DbProvider : IDbProvider
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 Microsoft.Data.SqlClient applies as usual.
Dialect is the SQL Server 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 = "dbo")
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 dbo.
Properties
Example
using CodeEffects.Rule.Connection.SqlServer;
var dbProvider = new DbProvider(builder.Configuration.GetConnectionString("Rules"));
builder.Services.AddSingleton<CodeEffects.Rule.Connection.IDbProvider>(dbProvider);