CSharpDB.Engine
Top-level database API, snapshot readers, and typed Collection<T> access.
Database
The primary entry point for embedded database usage. Manages the storage engine, SQL execution, transactions, and collection access.
Static Factory Methods
OpenAsync(string path) → ValueTask<Database>OpenAsync(string path, DatabaseOptions options) → ValueTask<Database>OpenInMemoryAsync() → ValueTask<Database>OpenInMemoryAsync(DatabaseOptions options) → ValueTask<Database>LoadIntoMemoryAsync(string path) → ValueTask<Database>LoadIntoMemoryAsync(string path, DatabaseOptions options) → ValueTask<Database>OpenHybridAsync(string path) → ValueTask<Database>OpenHybridAsync(string path, DatabaseOptions options, HybridDatabaseOptions hybridOptions) → ValueTask<Database>SQL Execution
ExecuteAsync(string sql) → ValueTask<QueryResult>Collections
GetCollectionAsync<T>(string name) → ValueTask<Collection<T>>Transactions
BeginTransactionAsync() → ValueTaskCommitAsync() → ValueTaskRollbackAsync() → ValueTaskMaintenance & Snapshots
CheckpointAsync() → ValueTaskSaveToFileAsync(string filePath) → ValueTaskCreateReaderSession() → ReaderSessionCollection<T>
Typed NoSQL document collection with JSON serialization, string keys, and path-based indexing.
CRUD
PutAsync(string key, T document) → ValueTaskGetAsync(string key) → ValueTask<T?>DeleteAsync(string key) → ValueTask<bool>CountAsync() → ValueTask<long>ScanAsync() → IAsyncEnumerable<KeyValuePair<string, T>>Querying
FindAsync(Func<T, bool> predicate) → IAsyncEnumerable<KeyValuePair<string, T>>FindByIndexAsync<TField>(Expression<Func<T, TField>> fieldSelector, TField value) → IAsyncEnumerable<KeyValuePair<string, T>>FindByPathAsync<TField>(string fieldPath, TField value) → IAsyncEnumerable<KeyValuePair<string, T>>FindByPathRangeAsync<TField>(string fieldPath, TField lowerBound, TField upperBound, ...) → IAsyncEnumerable<KeyValuePair<string, T>>Indexing
EnsureIndexAsync<TField>(Expression<Func<T, TField>> fieldSelector) → ValueTaskEnsureIndexAsync(string fieldPath) → ValueTaskReaderSession
Snapshot-isolated read-only session. Only one active query can exist per reader session at a time.
ExecuteReadAsync(string sql) → ValueTask<QueryResult>ExecuteReadAsync(Statement stmt) → ValueTask<QueryResult>Dispose() → voidQueryResult
Streaming query result for SQL execution and reader sessions.
MoveNextAsync() → ValueTask<bool>Current → DbValue[]Schema → ColumnDefinition[]RowsAffected → intToListAsync() → ValueTask<List<DbValue[]>>GetRowsAsync() → IAsyncEnumerable<DbValue[]>CSharpDB.Primitives
Primitive types, schemas, and exceptions.
DbType
The five fundamental data types supported by the database.
Null — Absence of valueInteger — 64-bit signed integerReal — 64-bit floating pointText — UTF-8 stringBlob — Raw byte arrayDbValue
A dynamically-typed database value wrapping one of the five core types.
Static Factory Methods
FromInteger(long value) → DbValueFromReal(double value) → DbValueFromText(string value) → DbValueFromBlob(byte[] value) → DbValueProperties
Type → DbTypeAsInteger → longAsReal → doubleAsText → stringAsBlob → byte[]IsNull → boolIsTruthy → boolStatic Methods
Compare(DbValue a, DbValue b) → intTableSchema
Defines the structure of a database table.
Constructor
TableSchema(string name, ColumnDefinition[] columns)Properties
Name → stringColumns → IReadOnlyList<ColumnDefinition>PrimaryKeyColumnIndex → intMethods
GetColumnIndex(string name) → intCreateJoinSchema(TableSchema other) → TableSchemaIndexSchema
Defines a secondary index on table columns.
Name → stringTableName → stringColumns → string[]IsUnique → boolCSharpDB.Storage.Paging
Page I/O, transaction management, and buffer coordination.
Pager
Core page I/O manager. Handles single-writer transactions, WAL integration, and dirty page tracking.
Transaction Methods
BeginTransactionAsync() → ValueTaskCommitAsync() → ValueTaskRollbackAsync() → ValueTaskPage Operations
GetPageAsync(uint pageId) → ValueTask<byte[]>AllocatePageAsync() → ValueTask<uint>MarkDirtyAsync(uint pageId) → ValueTaskSnapshot
AcquireReaderSnapshot() → WalSnapshotCreateSnapshotReader(WalSnapshot snapshot) → PagerReleaseReaderSnapshot() → voidSlottedPage
In-memory page abstraction. 4096-byte slotted format with cell pointer array and cell data.
CSharpDB.Storage.BTree
Persistent B+tree keyed by long rowid.
BTree
InsertAsync(long key, ReadOnlyMemory<byte> payload) → ValueTaskFindAsync(long key) → ValueTask<byte[]?>DeleteAsync(long key) → ValueTask<bool>CreateCursor() → BTreeCursorBTreeCursor
MoveNextAsync() → ValueTask<bool>SeekAsync(long targetKey) → ValueTask<bool>CurrentKey → longCurrentValue → ReadOnlyMemory<byte>CSharpDB.Storage.Catalog
Schema metadata management.
SchemaCatalog
Tables
CreateTableAsync(TableSchema schema) → ValueTaskGetTable(string tableName) → TableSchema?DropTableAsync(string tableName) → ValueTaskGetTableTree(string tableName) → BTreeIndexes
CreateIndexAsync(IndexSchema schema) → ValueTaskGetIndex(string indexName) → IndexSchema?DropIndexAsync(string indexName) → ValueTaskViews & Triggers
CreateViewAsync(string viewName, string sql) → ValueTaskCreateTriggerAsync(TriggerSchema schema) → ValueTaskCSharpDB.Storage.Indexing
Secondary index implementations with B+tree backing.
BTreeIndexStore
FindAsync(long key) → ValueTask<byte[]?>FindMaxKeyAsync(IndexScanRange range) → ValueTask<long?>InsertAsync(long key, ReadOnlyMemory<byte> payload) → ValueTaskReplaceAsync(long key, ReadOnlyMemory<byte> payload) → ValueTask<bool>DeleteAsync(long key) → ValueTask<bool>CreateCursor(IndexScanRange range) → IIndexCursorCachingIndexStore
Wraps an IIndexStore with an in-memory cache for frequently accessed index entries.
CSharpDB.Storage.Wal
Write-ahead log for durability and crash recovery.
WriteAheadLog
WriteFrameAsync(WalFrameWrite frame) → ValueTaskRecoverAsync() → ValueTaskCheckpointAsync() → ValueTaskCheckpointCoordinator
Manages checkpoint scheduling based on configured policies.
CheckpointIfNeededAsync() → ValueTaskForceCheckpointAsync() → ValueTaskCSharpDB.Storage.Serialization
Record and schema encoding/decoding.
DefaultRecordSerializer
Encode(DbValue[] values) → byte[]Decode(byte[] data, TableSchema schema) → DbValue[]CSharpDB.Data
Standard ADO.NET provider for CSharpDB.
CSharpDbConnection
Implements DbConnection. Connection string format: Data Source=path.db
CSharpDbConnection(string connectionString)OpenAsync() → TaskCreateCommand() → CSharpDbCommandBeginTransactionAsync() → ValueTask<DbTransaction>SaveToFileAsync(string filePath) → ValueTaskClearPool(string connectionString) → voidClearAllPools() → voidCSharpDbCommand
Implements DbCommand. Supports parameterized SQL execution.
CommandText → stringParameters → CSharpDbParameterCollectionExecuteNonQueryAsync() → Task<int>ExecuteReaderAsync() → Task<DbDataReader>ExecuteScalarAsync() → Task<object?>CSharpDbDataReader
Implements DbDataReader. Provides column accessors for query results.
ReadAsync() → Task<bool>GetString(int ordinal) → stringGetInt64(int ordinal) → longGetDouble(int ordinal) → doubleIsDBNull(int ordinal) → boolFieldCount → intGetName(int ordinal) → stringCSharpDbParameterCollection
Provider-specific parameter collection exposed by CSharpDbCommand.Parameters.
AddWithValue(string name, object? value) → CSharpDbParameterAdd(object value) → intClear() → voidCSharpDB.Client
Unified client SDK with pluggable transports.
CSharpDbClient
Unified client interface supporting Direct, HTTP, and gRPC transports.
Factory
Create(CSharpDbClientOptions options) → ICSharpDbClientRepresentative Operations
GetInfoAsync() → Task<DatabaseInfo>GetTableNamesAsync() → Task<IReadOnlyList<string>>GetTableSchemaAsync(string tableName) → Task<TableSchema?>ExecuteSqlAsync(string sql) → Task<SqlExecutionResult>ExecuteProcedureAsync(string name, IReadOnlyDictionary<string, object?> args) → Task<ProcedureExecutionResult>BeginTransactionAsync() → Task<TransactionSessionInfo>ExecuteInTransactionAsync(string transactionId, string sql) → Task<SqlExecutionResult>GetCollectionNamesAsync() → Task<IReadOnlyList<string>>GetDocumentAsync(string collectionName, string key) → Task<JsonElement?>PutDocumentAsync(string collectionName, string key, JsonElement document) → TaskCheckpointAsync() → TaskBackupAsync(BackupRequest request) → Task<BackupResult>CSharpDB.Pipelines
ETL pipeline orchestration and execution.
PipelineOrchestrator
Executes pipeline packages from definition to completion.
ExecuteAsync(PipelineRunRequest request) → Task<PipelineRunResult>PipelinePackageDefinition
JSON-serializable pipeline definition with source, transforms, and destination.
Name → stringVersion → stringDescription → string?Source → PipelineSourceDefinitionTransforms → IReadOnlyList<PipelineTransformDefinition>Destination → PipelineDestinationDefinitionOptions → PipelineExecutionOptionsIncremental → PipelineIncrementalOptions?PipelinePackageValidator
Validates pipeline definitions for correctness before execution.
Validate(PipelinePackageDefinition package) → PipelineValidationResultPipelinePackageSerializer
Serializes pipeline definitions to and from the JSON package format.
Serialize(PipelinePackageDefinition package) → stringDeserialize(string json) → PipelinePackageDefinitionSaveToFileAsync(PipelinePackageDefinition package, string path) → TaskLoadFromFileAsync(string path) → Task<PipelinePackageDefinition>PipelineExecutionMode
ValidateDryRunRunResumeCSharpDB.Storage.Diagnostics
Inspection and validation utilities.
DatabaseInspector
Full database inspection: file header validation, page walks, B+tree consistency, page histograms.
InspectAsync(string dbPath) → Task<DatabaseInspectReport>WalInspector
Validates WAL header, frame salts, and checksums for each committed frame.
InspectAsync(string walPath) → Task<WalReport>IndexInspector
Verifies index root page validity, table/column references, and B+tree reachability.
InspectAsync(string dbPath) → Task<IndexReport>