Class SqliteProvider
implementation for SQLite (via Microsoft.Data.Sqlite).
SQLite has no TRUNCATE, no server-side sequences, and no bulk-copy protocol,
so this provider uses DELETE FROM for cleaning, the AUTOINCREMENT high-water
mark in sqlite_sequence (row _global_identity) for the identity counter,
and batched parameterized INSERTs inside a single transaction for bulk import.
Foreign keys are toggled per-connection via PRAGMA foreign_keys (they default to
OFF in Microsoft.Data.Sqlite and must be enabled per connection, never inside a transaction).
public sealed class SqliteProvider : IDataProvider, IAsyncDisposable
Inheritance
Implements
Properties
Methods
AbortImportAsync()
Rolls back whatever the import wrote and restores the session state it changed. Called on every path
public Task AbortImportAsync()
BeginImportAsync(CancellationToken)
Starts the import transaction. Everything the import writes from here on - cleaning, rows, the
public Task BeginImportAsync(CancellationToken ct = default)
BulkInsertAsync(string, DataTable, CancellationToken)
Performs a bulk insert of the supplied
public Task BulkInsertAsync(string tableName, DataTable data, CancellationToken ct = default)
CleanDatabaseAsync(CancellationToken)
Truncates all REDB tables in the correct foreign-key order, leaving the schema intact.
public Task CleanDatabaseAsync(CancellationToken ct = default)
CommitImportAsync(CancellationToken)
Commits the import transaction and restores the session state the import changed.
public Task CommitImportAsync(CancellationToken ct = default)
DisableConstraintsAsync(CancellationToken)
Disables foreign-key constraints and triggers so that rows can be
public Task DisableConstraintsAsync(CancellationToken ct = default)
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public ValueTask DisposeAsync()
EnableConstraintsAsync(CancellationToken)
Re-enables foreign-key constraints and triggers after bulk import.
public Task EnableConstraintsAsync(CancellationToken ct = default)
ExecuteAsync(string, CancellationToken)
Executes a statement that returns no rows (DDL included). Inside an import it runs in the
public Task ExecuteAsync(string sql, CancellationToken ct = default)
GetSequenceValueAsync(CancellationToken)
Returns the current value of the global_identity sequence.
public Task<long> GetSequenceValueAsync(CancellationToken ct = default)
GuidFromDb(object)
Reads a uuid-semantic column value into its portable form.
public Guid GuidFromDb(object raw)
GuidToDb(Guid)
Converts a portable into the value this provider stores in a
public object GuidToDb(Guid value)
OpenAsync(string, CancellationToken)
Opens a connection to the database using the supplied connection string.
public Task OpenAsync(string connectionString, CancellationToken ct = default)
ReadDateTimeOffset(DbDataReader, int)
Reads a date column of a redb table into its portable form.
public DateTimeOffset ReadDateTimeOffset(DbDataReader reader, int ordinal)
SetSequenceValueAsync(long, CancellationToken)
Resets the global_identity sequence to the specified value
public Task SetSequenceValueAsync(long value, CancellationToken ct = default)