CSharpDB.Service 1.7.0

Prefix Reserved
dotnet add package CSharpDB.Service --version 1.7.0
                    
NuGet\Install-Package CSharpDB.Service -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.Service" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharpDB.Service" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="CSharpDB.Service" />
                    
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.Service --version 1.7.0
                    
#r "nuget: CSharpDB.Service, 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.Service@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.Service&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=CSharpDB.Service&version=1.7.0
                    
Install as a Cake Tool

CSharpDB.Service

Compatibility facade for hosting CSharpDB in ASP.NET Core, Blazor, or MCP server applications.

NuGet .NET 10 Release License: MIT

Overview

CSharpDB.Service now delegates to CSharpDB.Client.

Its purpose is transition compatibility for existing in-process hosts that still inject CSharpDbService. The authoritative database API lives in CSharpDB.Client; this package preserves the old DI shape, events, and model surface while the repo retires direct service usage.

Features

  • Compatibility layer: Existing hosts can keep injecting CSharpDbService
  • Thread-safe wrapper: Calls are serialized via SemaphoreSlim
  • DI-ready: Constructor still reads the "CSharpDB" connection string from IConfiguration
  • Event bridge: Preserves TablesChanged, SchemaChanged, and ProceduresChanged
  • Delegates to client: Schema, CRUD, SQL, procedures, saved queries, and diagnostics now flow through CSharpDB.Client

Usage

ASP.NET Core Registration

// appsettings.json
{
    "ConnectionStrings": {
        "CSharpDB": "Data Source=myapp.db"
    }
}

// Program.cs
builder.Services.AddSingleton<CSharpDbService>();

Service API

using CSharpDB.Service;

public class MyController(CSharpDbService db)
{
    // Browse a table with pagination
    public async Task<TableBrowseResult> GetUsers(int page = 1)
        => await db.BrowseTableAsync("users", page, pageSize: 25);

    // Get a single row by primary key
    public async Task<Dictionary<string, object?>> GetUser(string pk)
        => await db.GetRowByPkAsync("users", pk);

    // Insert a row
    public async Task CreateUser(Dictionary<string, string?> values)
        => await db.InsertRowAsync("users", values);

    // Execute arbitrary SQL
    public async Task<SqlExecutionResult> RunSql(string sql)
        => await db.ExecuteSqlAsync(sql);

    // Schema introspection
    public async Task<List<string>> GetTables()
        => await db.GetTableNamesAsync();

    // Storage diagnostics
    public async Task<object> InspectDatabase()
        => await db.InspectStorageAsync();
}

Schema Management

// DDL operations
await db.CreateIndexAsync("users", "idx_email", "email", isUnique: true);
await db.CreateViewAsync("active_users", "SELECT * FROM users WHERE active = 1");
await db.RenameTableAsync("users", "app_users");
await db.AddColumnAsync("app_users", "created_at", "TEXT");
await db.DropColumnAsync("app_users", "legacy_field");

Storage Diagnostics

// Inspect the database file
var report = await db.InspectStorageAsync();

// Check WAL integrity
var walReport = await db.CheckWalAsync();

// Inspect a specific page
var pageInfo = await db.InspectPageAsync(pageId: 5);

// Verify all indexes
var indexReport = await db.CheckIndexesAsync();

Procedure Catalog

using CSharpDB.Core;
using CSharpDB.Service.Models;

await db.CreateProcedureAsync(new ProcedureDefinition
{
    Name = "GetUserById",
    BodySql = "SELECT * FROM users WHERE id = @id;",
    Parameters =
    [
        new ProcedureParameterDefinition
        {
            Name = "id",
            Type = DbType.Integer,
            Required = true,
        }
    ],
    IsEnabled = true,
    CreatedUtc = DateTime.UtcNow,
    UpdatedUtc = DateTime.UtcNow,
});

var execution = await db.ExecuteProcedureAsync("GetUserById", new Dictionary<string, object?>
{
    ["id"] = 1L,
});

Result Models

Model Description
SqlExecutionResult Query/DML result with IsQuery, ColumnNames, Rows, RowsAffected, Error, Elapsed
TableBrowseResult Paginated table data with Schema, Rows, TotalRows, Page, PageSize, TotalPages
ViewBrowseResult View query results
ViewDefinition View name and defining SQL
ProcedureDefinition Procedure metadata: name, body SQL, params, enabled flag, timestamps
ProcedureExecutionResult Procedure execution summary with per-statement results and rollback-safe error info

Installation

dotnet add package CSharpDB.Service

For the recommended all-in-one package:

dotnet add package CSharpDB

Dependencies

  • CSharpDB.Client - authoritative database API
  • CSharpDB.Sql - SQL splitting for compatibility event notifications
  • Microsoft.Extensions.Configuration.Abstractions - configuration binding
Package Description
CSharpDB.Data Underlying ADO.NET provider
CSharpDB.Engine Embedded database engine

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.Service:

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 36 3/8/2026
1.5.0 36 3/7/2026
1.4.0 34 3/7/2026
1.3.0 37 3/6/2026
1.2.0 35 3/5/2026
1.1.0 37 3/4/2026