Class RedbContextBase
Base class for REDB context.
Provides common logic and shortcuts.
DB-specific implementations inherit from this.
public abstract class RedbContextBase : IRedbContext, IAsyncDisposable, IDisposable
Inheritance
Implements
Derived
Properties
BulkOperations
The provider's bulk operations.
protected abstract IBulkOperations BulkOperations { get; }
IsDisposed
True once the context has been disposed - the scope that owned it has ended (V4, review).
public bool IsDisposed { get; }
IsInTransaction
Whether any transaction is active — explicit or ambient TransactionScope.
public bool IsInTransaction { get; }
Methods
BeginTransactionAsync(IsolationLevel?, CancellationToken)
Begin new transaction.
public Task<IRedbTransaction> BeginTransactionAsync(IsolationLevel? isolationLevel = null, CancellationToken cancellationToken = default)
DisposeAsync()
Dispose context and all components asynchronously.
public virtual ValueTask DisposeAsync()
ExecuteAsync(string, object[], CancellationToken)
Cancellable form.
public Task<int> ExecuteAsync(string sql, object[] parameters, CancellationToken cancellationToken)
ExecuteAsync(string, params object[])
Execute SQL command (INSERT, UPDATE, DELETE).
public Task<int> ExecuteAsync(string sql, params object[] parameters)
ExecuteAtomicAsync(Func<Task>, CancellationToken)
Execute operations atomically.
public Task ExecuteAtomicAsync(Func<Task> operations, CancellationToken cancellationToken = default)
ExecuteAtomicAsync(Func<Task>)
Execute operations atomically.
public Task ExecuteAtomicAsync(Func<Task> operations)
ExecuteAtomicAsync(IsolationLevel, Func<Task>, CancellationToken)
Atomic execution under an explicit isolation level (BR-1). An active or ambient transaction
public Task ExecuteAtomicAsync(IsolationLevel isolationLevel, Func<Task> operations, CancellationToken cancellationToken = default)
ExecuteAtomicAsync<T>(Func<Task<T>>, CancellationToken)
Execute operations atomically and return result.
public Task<T> ExecuteAtomicAsync<T>(Func<Task<T>> operations, CancellationToken cancellationToken = default)
ExecuteAtomicAsync<T>(Func<Task<T>>)
Execute operations atomically and return result.
public Task<T> ExecuteAtomicAsync<T>(Func<Task<T>> operations)
ExecuteAtomicAsync<T>(IsolationLevel, Func<Task<T>>, CancellationToken)
Result-returning form of the isolation-level overload (BR-1).
public Task<T> ExecuteAtomicAsync<T>(IsolationLevel isolationLevel, Func<Task<T>> operations, CancellationToken cancellationToken = default)
ExecuteJsonAsync(string, object[], CancellationToken)
Cancellable form.
public Task<string?> ExecuteJsonAsync(string sql, object[] parameters, CancellationToken cancellationToken)
ExecuteJsonAsync(string, params object[])
Execute SQL returning JSON.
public Task<string?> ExecuteJsonAsync(string sql, params object[] parameters)
ExecuteJsonListAsync(string, object[], CancellationToken)
Cancellable form.
public Task<List<string>> ExecuteJsonListAsync(string sql, object[] parameters, CancellationToken cancellationToken)
ExecuteJsonListAsync(string, params object[])
Execute SQL returning multiple JSON rows.
public Task<List<string>> ExecuteJsonListAsync(string sql, params object[] parameters)
ExecuteScalarAsync<T>(string, object[], CancellationToken)
Cancellable form.
public Task<T?> ExecuteScalarAsync<T>(string sql, object[] parameters, CancellationToken cancellationToken)
ExecuteScalarAsync<T>(string, params object[])
Execute SQL query and return scalar value.
public Task<T?> ExecuteScalarAsync<T>(string sql, params object[] parameters)
NextObjectIdAsync(CancellationToken)
Get next object ID.
public Task<long> NextObjectIdAsync(CancellationToken cancellationToken = default)
NextObjectIdBatchAsync(int, CancellationToken)
Get batch of object IDs.
public Task<long[]> NextObjectIdBatchAsync(int count, CancellationToken cancellationToken = default)
NextObjectIdBatchAsync(int)
Get batch of object IDs.
public Task<long[]> NextObjectIdBatchAsync(int count)
NextValueIdAsync(CancellationToken)
Get next value ID.
public Task<long> NextValueIdAsync(CancellationToken cancellationToken = default)
NextValueIdBatchAsync(int, CancellationToken)
Get batch of value IDs.
public Task<long[]> NextValueIdBatchAsync(int count, CancellationToken cancellationToken = default)
NextValueIdBatchAsync(int)
Get batch of value IDs.
public Task<long[]> NextValueIdBatchAsync(int count)
QueryAsync<T>(string, object[], CancellationToken)
Cancellable form: parameters as an explicit array (params cannot precede ct).
public Task<List<T>> QueryAsync<T>(string sql, object[] parameters, CancellationToken cancellationToken) where T : new()
QueryAsync<T>(string, params object[])
Execute SQL query and return list of mapped objects.
public Task<List<T>> QueryAsync<T>(string sql, params object[] parameters) where T : new()
QueryFirstOrDefaultAsync<T>(string, object[], CancellationToken)
Cancellable form.
public Task<T?> QueryFirstOrDefaultAsync<T>(string sql, object[] parameters, CancellationToken cancellationToken) where T : class, new()
QueryFirstOrDefaultAsync<T>(string, params object[])
Execute SQL query and return first result or null.
public Task<T?> QueryFirstOrDefaultAsync<T>(string sql, params object[] parameters) where T : class, new()
QueryRowsAsJsonAsync(string, object[], CancellationToken)
The rows of sql as a JSON array of objects keyed by column name, NULL values included;
public Task<string> QueryRowsAsJsonAsync(string sql, object[] parameters, CancellationToken cancellationToken = default)
QueryRowsAsJsonCoreAsync(string, object[], CancellationToken)
The provider's row-to-JSON read behind , run on : every
protected abstract Task<string> QueryRowsAsJsonCoreAsync(string sql, object[] parameters, CancellationToken cancellationToken)
QueryScalarListAsync<T>(string, object[], CancellationToken)
Cancellable form.
public Task<List<T>> QueryScalarListAsync<T>(string sql, object[] parameters, CancellationToken cancellationToken)
QueryScalarListAsync<T>(string, params object[])
Execute SQL query and return list of scalar values (first column only).
public Task<List<T>> QueryScalarListAsync<T>(string sql, params object[] parameters)