DbHub 1.0.0
dotnet add package DbHub --version 1.0.0
NuGet\Install-Package DbHub -Version 1.0.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="DbHub" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DbHub" Version="1.0.0" />
<PackageReference Include="DbHub" />
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 DbHub --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DbHub, 1.0.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 DbHub@1.0.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=DbHub&version=1.0.0
#tool nuget:?package=DbHub&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DbHub
DbHub is a .NET 10 generic database execution engine built with Clean Architecture and Clean Code principles. It provides a unified API to connect to multiple database providers and execute queries, stored procedures, non-query commands, and scalar operations — with built-in Redis caching and MongoDB-based connection configuration.
Features
- ✅ Multi-provider: SQL Server, MySQL, Oracle, MongoDB
- ✅ Strategy pattern: Easily add new database providers
- ✅ Redis caching: Connection strings are cached automatically
- ✅ MongoDB config store: Connection and procedure configurations stored in MongoDB
- ✅ Fully async: All operations are
async/awaitwithCancellationTokensupport - ✅ Strongly typed generics: Results mapped to your models
- ✅ SOLID & Clean Architecture: Domain → Application → Infrastructure
Installation
dotnet add package DbHub
Quick Start
1. Register services
// Program.cs
builder.Services.AddDbHub(options =>
{
options.MongoDbConnectionString = "mongodb://localhost:27017";
options.MongoDbDatabase = "DbHubConfig";
options.RedisConnectionString = "localhost:6379";
options.CacheExpiry = TimeSpan.FromHours(1);
});
2. Store a connection configuration in MongoDB
Insert a document into the ConnectionConfigs collection:
{
"AppKey": "MyApp",
"ConnectionType": 1,
"DatabaseKey": "MainDb",
"Server": "localhost",
"Database": "MyDatabase",
"User": "sa",
"Password": "YourPassword",
"Provider": "MSSQL",
"Port": 0,
"AdditionalSettings": {}
}
ConnectionTypevalues:1= MSSQL,2= MYSQL,3= ORACLE,4= MONGODB
3. Execute operations
public class UserService(IDbHubService dbHub)
{
public Task<IEnumerable<UserDto>> GetAllAsync(CancellationToken ct) =>
dbHub.ExecuteQueryAsync<UserDto>(new DbHubRequest
{
AppKey = "MyApp",
ConnectionType = ConnectionType.MSSQL,
DatabaseKey = "MainDb",
CommandText = "SELECT Id, Name, Email FROM Users WHERE IsActive = @IsActive",
Params =
[
new DbHubParameter { Name = "IsActive", Value = true, Type = DbType.Boolean }
]
}, ct);
public Task<IEnumerable<UserDto>> GetByStoredProcedureAsync(CancellationToken ct) =>
dbHub.ExecuteStoredProcedureAsync<UserDto>(new DbHubRequest
{
AppKey = "MyApp",
ConnectionType = ConnectionType.MSSQL,
DatabaseKey = "MainDb",
ProcedureKey = "GET_ACTIVE_USERS"
}, ct);
public Task<int> InsertAsync(string name, CancellationToken ct) =>
dbHub.ExecuteNonQueryAsync(new DbHubRequest
{
AppKey = "MyApp",
ConnectionType = ConnectionType.MSSQL,
DatabaseKey = "MainDb",
CommandText = "INSERT INTO Users (Name) VALUES (@Name)",
Params = [new DbHubParameter { Name = "Name", Value = name }]
}, ct);
public Task<int?> CountAsync(CancellationToken ct) =>
dbHub.ExecuteScalarAsync<int?>(new DbHubRequest
{
AppKey = "MyApp",
ConnectionType = ConnectionType.MSSQL,
DatabaseKey = "MainDb",
CommandText = "SELECT COUNT(*) FROM Users"
}, ct);
}
MongoDB Provider
| Operation | Behavior |
|---|---|
ExecuteQueryAsync<T> |
Finds documents. CommandText = collection name. Params = equality filters. |
ExecuteStoredProcedureAsync<T> |
Runs aggregation pipeline. procedureName = collection. CommandText = JSON pipeline array. |
ExecuteNonQueryAsync |
Deletes matching documents. CommandText = collection. Params = filter. Returns deleted count. |
ExecuteScalarAsync<T> |
Counts matching documents. CommandText = collection. Params = filter. |
Architecture
DbHub ← Public NuGet entry point
DbHub.Infrastructure ← Providers, repositories, cache, DI
DbHub.Application ← Interfaces, services, request models
DbHub.Domain ← Entities, interfaces
DbHub.Shared ← Enums, models, utilities
| Product | Versions 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.
-
net10.0
- Dapper (>= 2.1.72)
- DbHub.Application (>= 1.0.0)
- DbHub.Domain (>= 1.0.0)
- DbHub.Infrastructure (>= 1.0.0)
- DbHub.Shared (>= 1.0.0)
- Microsoft.Data.SqlClient (>= 6.1.4)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
- Microsoft.Extensions.Options (>= 10.0.4)
- MongoDB.Driver (>= 3.7.0)
- MySqlConnector (>= 2.5.0)
- Oracle.ManagedDataAccess.Core (>= 23.26.100)
- StackExchange.Redis (>= 2.11.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 114 | 3/11/2026 |