Apq.Cfg.Database
1.0.4
dotnet add package Apq.Cfg.Database --version 1.0.4
NuGet\Install-Package Apq.Cfg.Database -Version 1.0.4
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="Apq.Cfg.Database" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Apq.Cfg.Database" Version="1.0.4" />
<PackageReference Include="Apq.Cfg.Database" />
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 Apq.Cfg.Database --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Apq.Cfg.Database, 1.0.4"
#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 Apq.Cfg.Database@1.0.4
#: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=Apq.Cfg.Database&version=1.0.4
#tool nuget:?package=Apq.Cfg.Database&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Apq.Cfg.Database
数据库配置源扩展包,支持多种数据库。
仓库地址:https://gitee.com/apq/Apq.Cfg
依赖
- Apq.Cfg
- SqlSugarCore 5.1.4.210
支持的数据库
- SQL Server
- MySQL
- PostgreSQL
- Oracle
- SQLite
用法
using Apq.Cfg;
using Apq.Cfg.Database;
var cfg = new CfgBuilder()
.AddDatabase(options =>
{
options.Provider = "SqlServer";
options.ConnectionString = "Server=localhost;Database=ConfigDb;...";
options.Table = "AppConfig";
options.KeyColumn = "ConfigKey";
options.ValueColumn = "ConfigValue";
}, level: 1, isPrimaryWriter: true)
.Build();
// 读取配置
var connStr = cfg.Get("Database:ConnectionString");
var timeout = cfg.Get<int>("Database:Timeout");
方法签名
public static CfgBuilder AddDatabase(
this CfgBuilder builder,
Action<DatabaseOptions> configure,
int level,
bool isPrimaryWriter = false)
DatabaseOptions
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
Provider |
string? |
- | 数据库提供程序名称 |
ConnectionString |
string? |
- | 数据库连接字符串 |
Table |
string? |
- | 配置表名 |
KeyColumn |
string? |
- | 键列名 |
ValueColumn |
string? |
- | 值列名 |
CommandTimeoutMs |
int |
5000 | 命令超时(毫秒) |
Provider 值
| 值 | 数据库 |
|---|---|
SqlServer |
Microsoft SQL Server |
MySql |
MySQL |
PostgreSQL 或 Postgres |
PostgreSQL |
Oracle |
Oracle |
SQLite |
SQLite |
数据表结构
CREATE TABLE AppConfig (
ConfigKey NVARCHAR(256) PRIMARY KEY,
ConfigValue NVARCHAR(MAX)
);
示例
SQL Server
.AddDatabase(options =>
{
options.Provider = "SqlServer";
options.ConnectionString = "Server=.;Database=MyDb;Trusted_Connection=True;";
options.Table = "AppConfig";
options.KeyColumn = "Key";
options.ValueColumn = "Value";
}, level: 1)
MySQL
.AddDatabase(options =>
{
options.Provider = "MySql";
options.ConnectionString = "Server=localhost;Database=mydb;User=root;Password=...;";
options.Table = "app_config";
options.KeyColumn = "config_key";
options.ValueColumn = "config_value";
}, level: 1)
SQLite
.AddDatabase(options =>
{
options.Provider = "SQLite";
options.ConnectionString = "Data Source=config.db";
options.Table = "Config";
options.KeyColumn = "Key";
options.ValueColumn = "Value";
}, level: 1)
许可证
MIT License
作者
- 邮箱:amwpfiqvy@163.com
仓库
- Gitee:https://gitee.com/apq/Apq.Cfg
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net6.0
- Apq.Cfg (>= 1.0.0)
- SqlSugarCore (>= 5.1.4.210)
-
net7.0
- Apq.Cfg (>= 1.0.0)
- SqlSugarCore (>= 5.1.4.210)
-
net8.0
- Apq.Cfg (>= 1.0.0)
- SqlSugarCore (>= 5.1.4.210)
-
net9.0
- Apq.Cfg (>= 1.0.0)
- SqlSugarCore (>= 5.1.4.210)
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.4 | 35 | 12/26/2025 |
| 1.0.3 | 95 | 12/25/2025 |
| 1.0.2 | 93 | 12/25/2025 |
| 1.0.1 | 104 | 12/24/2025 |
| 1.0.0 | 115 | 12/22/2025 |
| 0.0.1-beta4 | 101 | 12/20/2025 |
| 0.0.1-beta3 | 129 | 12/20/2025 |
| 0.0.1-beta2 | 130 | 12/20/2025 |
| 0.0.1-beta1 | 202 | 12/19/2025 |