Class RedbConnectionLease

Namespace: redb.Core.Data
Assembly: redb.Core.dll

The connection a redb connection works on, lent for the caller's own commands: the open connection, the
transaction the commands must run in, and a command factory bound to both. Taken by
, given back by .

The connection and the transaction stay redb's (or the ambient transaction's). While the lease is held the
holder must never: commit, roll back or dispose the transaction, or begin one of its own; close, dispose or
reopen the connection, or change its database; change session settings (SET, PRAGMA, isolation level);
leave a data reader open past the release; call redb on the same connection or in the same ambient
transaction (the call is refused at once); swallow a failure of its own command and go on with the
transaction (on PostgreSQL a failed command aborts the transaction for every later command).

public sealed class RedbConnectionLease : IAsyncDisposable

Inheritance

Object→RedbConnectionLease

Implements

Properties

Connection

The open connection. Not the holder's: never close, dispose or reopen it.

public DbConnection Connection { get; }

Transaction

The transaction every command of the holder must be bound to: redb's explicit transaction, or on SQLite

public DbTransaction? Transaction { get; }

Methods

CreateCommand()

A command on , bound to . The holder disposes it.

public DbCommand CreateCommand()

DisposeAsync()

Gives the connection back. The second call does nothing. Throws

public ValueTask DisposeAsync()

Constructors

RedbConnectionLease(DbConnection, DbTransaction?, Action)

A lease over connection. release gives the connection back (leaves