PostgreSQL · Types · Services and connections
ArxPgConnection
Definition
- Namespace
ARX.SDK.PostgreSql.Services- Package
ARX.SDK.PostgreSql
public sealed class ArxPgConnection : ArxConnectionA PostgreSQL connection for ARX transactions. Application code begins a transaction on it and passes the transaction to ArxPgDbService calls; it never needs an Npgsql type.
Constructor
ArxPgConnection(string connectionString)A connection for ARX transactions. It opens with the first BeginTransactionAsync.
Parameter Type Description connectionStringstringThe Npgsql connection string.
Usage
A line from a verified sample; the full, runnable code is on its page.
await using (var connection = new ArxPgConnection(dbContext.ConnectionString))Several calls in one ARX transaction: commit or roll back, scenario 1
Used in:
- Several calls in one ARX transaction: commit or roll backCreate
- Updates in one ARX transaction: commit, roll back, abortUpdate
- Deletes in one ARX transaction: roll back or commitDeleteMultiple
- Read your own writes in an ARX transactionRetrieve
- A nightly job that commits in batchesExecute
- Execute in an ARX transactionExecute
Notes
It wraps an NpgsqlConnection, which is sealed, so ARX can't derive from it. The connection opens on the first BeginTransactionAsync, with the session defaults of every connection ARX opens (Timezone=UTC unless the connection string names a zone), and closes on dispose. One transaction at a time, and one call at a time. Not thread-safe.