CSharpDB.Data 1.7.0

Prefix Reserved
dotnet add package CSharpDB.Data --version 1.7.0
                    
NuGet\Install-Package CSharpDB.Data -Version 1.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpDB.Data" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpDB.Data" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpDB.Data" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharpDB.Data --version 1.7.0
                    
#r "nuget: CSharpDB.Data, 1.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharpDB.Data@1.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharpDB.Data&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpDB.Data&version=1.7.0
                    
Install as a Cake Tool

CSharpDB.Data

ADO.NET provider for the CSharpDB embedded database engine. Standard DbConnection, DbCommand, and DbDataReader with parameterized queries and transactions.

NuGet .NET 10 Release License: MIT

Overview

CSharpDB.Data provides a standard System.Data.Common (ADO.NET) data provider for CSharpDB. Use familiar DbConnection/DbCommand/DbDataReader patterns to query and modify your embedded database. Supports parameterized queries, transactions, prepared statements, prepared-template caching, schema introspection, and both file-backed and in-memory connection modes.

Key Types

Type Description
CSharpDbConnection DbConnection for file-backed databases, private :memory: databases, and named shared :memory:name databases
CSharpDbCommand DbCommand with prepared statement support, template caching, and parameter binding
CSharpDbDataReader DbDataReader with async iteration, typed getters, and HasRows
CSharpDbTransaction DbTransaction with auto-rollback on dispose
CSharpDbFactory Singleton DbProviderFactory for creating connections and commands
CSharpDbParameter Parameter support with AddWithValue convenience method

Usage

using CSharpDB.Data;

// Open a connection
await using var connection = new CSharpDbConnection("Data Source=myapp.db");
await connection.OpenAsync();

// Create a table
await using var cmd = connection.CreateCommand();
cmd.CommandText = """
    CREATE TABLE products (
        id INTEGER PRIMARY KEY,
        name TEXT,
        price REAL
    )
    """;
await cmd.ExecuteNonQueryAsync();

// Insert with parameters
cmd.CommandText = "INSERT INTO products VALUES (@id, @name, @price)";
cmd.Parameters.AddWithValue("@id", 1);
cmd.Parameters.AddWithValue("@name", "Widget");
cmd.Parameters.AddWithValue("@price", 9.99);
await cmd.ExecuteNonQueryAsync();

// Query with a data reader
cmd.CommandText = "SELECT name, price FROM products WHERE price < @max";
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@max", 50.0);

await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    Console.WriteLine($"{reader.GetString(0)}: ${reader.GetDouble(1):F2}");
}

// Transactions
await using var tx = await connection.BeginTransactionAsync();
cmd.Transaction = (CSharpDbTransaction)tx;
cmd.CommandText = "INSERT INTO products VALUES (2, 'Gadget', 19.99)";
await cmd.ExecuteNonQueryAsync();
await tx.CommitAsync();

// Save an in-memory connection back to disk
await connection.SaveToFileAsync("products.db");

// Schema introspection
var csConn = (CSharpDbConnection)connection;
var tables = csConn.GetTableNames();
var schema = csConn.GetTableSchema("products");

Using DbProviderFactory

var factory = CSharpDbFactory.Instance;
await using var conn = factory.CreateConnection();
conn.ConnectionString = "Data Source=myapp.db";
await conn.OpenAsync();

In-Memory Connection Strings

Data Source=:memory:

Creates a private in-memory database scoped to a single connection.

Data Source=:memory:shared-cache

Creates or attaches to a named shared in-memory database within the current process.

Data Source=:memory:shared-cache;Load From=seed.db

Seeds an in-memory database from seed.db on first open. For named shared memory, later opens must either omit Load From or use the same source path.

Named shared in-memory connections allow multiple live connections at once. One connection may own an explicit transaction at a time; other connections can still run reads against the last committed snapshot while that transaction is active.

Connection Pooling (Opt-In)

Connection pooling is disabled by default. Enable it explicitly in the connection string:

Data Source=myapp.db;Pooling=true;Max Pool Size=16

To force-release pooled physical connections (for example before deleting database files):

CSharpDbConnection.ClearPool("Data Source=myapp.db;Pooling=true;Max Pool Size=16");
CSharpDbConnection.ClearAllPools();

ClearPool and ClearAllPools also clear named shared in-memory hosts.

Installation

dotnet add package CSharpDB.Data

For the recommended all-in-one package:

dotnet add package CSharpDB

Dependencies

  • CSharpDB.Engine - embedded database engine
Package Description
CSharpDB All-in-one package for application development
CSharpDB.Engine Underlying embedded database engine
CSharpDB.Service Thread-safe service layer built on this provider

License

MIT - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CSharpDB.Data:

Package Downloads
CSharpDB

All-in-one package for CSharpDB application development. Includes the unified client, engine, ADO.NET provider, service layer, and diagnostics.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 35 3/8/2026
1.6.0 37 3/8/2026
1.5.0 42 3/7/2026
1.4.0 36 3/7/2026
1.3.0 38 3/6/2026
1.2.0 66 3/5/2026
1.1.0 64 3/4/2026
1.0.0 80 3/1/2026