Class SqliteDataSource

Namespace: redb.SQLite.Data
Assembly: redb.SQLite.dll

Lightweight stand-in for Npgsql's NpgsqlDataSource concept.
Microsoft.Data.Sqlite has no DataSource type — it pools connections
internally, keyed by connection string. This wrapper centralizes
connection creation and applies the per-connection PRAGMAs that SQLite
requires on EVERY connection (they are not persistent):

foreign_keys=ON (so ON DELETE CASCADE / SET NULL fire)
busy_timeout (so a second writer waits instead of failing with
SQLITE_BUSY — SQLite is single-writer)

public sealed class SqliteDataSource : IDisposable

Inheritance

Object→SqliteDataSource

Implements

Properties

CacheSizeBytes

Size, in bytes, of the page cache of every connection (PRAGMA cache_size). 0, the

public static long CacheSizeBytes { get; set; }

ConnectionString

Connection string this data source opens.

public string ConnectionString { get; }

LazyReferences

V4 (LAZY Л2): arm redb_lazy_refs(1) on every open (the native extension keeps the flag per connection).

public bool LazyReferences { get; }

MmapSizeBytes

Size, in bytes, of the part of the database file every connection maps into memory

public static long MmapSizeBytes { get; set; }

NativeExtensionPath

Path to the REDB native loadable extension (redbsqlite.dll/.so/.dylib, WITHOUT

public static string? NativeExtensionPath { get; set; }

UnicodeCaseFolding

When true, every opened connection gets like, lower and upper

public bool UnicodeCaseFolding { get; }

Methods

Create(string, bool, bool)

V4 (LAZY Л2): also arms the lazy-references connection flag of the native extension.

public static SqliteDataSource Create(string connectionString, bool unicodeCaseFolding, bool lazyReferences)

Create(string, bool)

Create a data source that additionally installs Unicode-aware case folding on every

public static SqliteDataSource Create(string connectionString, bool unicodeCaseFolding)

Create(string)

Create a data source for the given connection string.

public static SqliteDataSource Create(string connectionString)

Dispose()

Releases the connection pool of this data source's connection string. The pools of

public void Dispose()

LocatePackagedExtension()

Locate the REDB native extension shipped inside the NuGet package, relative to

public static string? LocatePackagedExtension()

OpenConnection()

Open a new pooled connection with REDB pragmas applied.

public SqliteConnection OpenConnection()

OpenConnectionAsync()

Open a new pooled connection with REDB pragmas applied.

public Task<SqliteConnection> OpenConnectionAsync()