DotNetCore.CAP.GaussDB 10.0.2

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

DotNetCore.CAP.GaussDB

NuGet License

DotNetCore.CAP.GaussDB 是 CAP 分布式事务/EventBus 框架的 华为云 GaussDB 存储提供程序,为 CAP 提供基于 GaussDB 数据库的消息持久化、分布式锁和监控能力。


特性

  • 支持 GaussDB 多种数据库兼容模式
  • 支持 ADO.NET 直接连接与 EF Core 绑定两种配置方式
  • 跟随 CAP 面向 .NET 8、.NET 9、.NET 10 发布

支持的 GaussDB 兼容模式

兼容模式 说明
Oracle datcompatibility = 'A' 或 'ORA'
MySQL datcompatibility = 'B' 或 'MYSQL'
Teradata datcompatibility = 'C' 或 'TD'
PostgreSQL datcompatibility = 'PG'
M-Compatibility datcompatibility = 'M'(MySQL 风格反引号语法)

启动时会自动探测数据库兼容模式,根据模式选择对应的 SQL 方言(标识符引用、数据类型、时间函数等)。


安装

dotnet add package DotNetCore.CAP.GaussDB

依赖:HuaweiCloud.GaussDB.Driver 作为 ADO.NET 驱动。


快速开始

1. 使用连接字符串(ADO.NET)

services.AddCap(x =>
{
    x.UseGaussDB("host=xxxx;port=xxxx;uid=xxxx;pwd=your_password;Database=mydb;sslmode=Disable");
    x.UseRabbitMQ("...");  // 任选一种消息队列传输器
});

2. 使用配置委托

services.AddCap(x =>
{
    x.UseGaussDB(opt =>
    {
        opt.ConnectionString = "host=xxxx;port=xxxx;uid=xxxx;pwd=your_password;Database=mydb";
        opt.Schema = "cap";                     // 默认值 "cap"
        opt.AdminDatabaseName = "postgres";     // 启动时用于探测数据库存在的管理库
        opt.StartupCheckDatabaseExistsMaxRetries = 5;   // 数据库存在性探测重试次数
        opt.StartupCheckDatabaseExistsBaseDelay = TimeSpan.FromSeconds(1);  // 基础重试间隔
        opt.StartupCheckDatabaseExistsMaxDelay = TimeSpan.FromMinutes(1);   // 最大重试间隔
    });
});

3. 使用 EF Core(从 DbContext 自动读取连接信息)

services.AddDbContext<AppDbContext>(options =>
    options.UseGaussDB("host=xxxx;port=xxxx;uid=xxxx;pwd=your_password;Database=mydb"));

services.AddCap(x =>
{
    x.UseEntityFramework<AppDbContext>(ef =>
    {
        ef.Schema = "cap";  // 可覆盖 Schema
    });
    x.UseRabbitMQ("...");
});

配置参数

GaussDBOptions

参数 类型 默认值 说明
ConnectionString string? null GaussDB 连接字符串
DataSource GaussDBDataSource? null 复用外部 GaussDB 数据源(优先级高于 ConnectionString)
Schema string "cap" 存储 CAP 消息表的 Schema 名
AdminDatabaseName string "postgres" 启动时用于探测目标数据库是否存在的管理数据库
EnableAutoSetNoResetOnClose bool true 是否自动追加 No Reset On Close=True,避免连接池归还时重置会话状态
StartupCheckDatabaseExistsMaxRetries int 5 启动时目标数据库存在性探测最大重试次数
StartupCheckDatabaseExistsBaseDelay TimeSpan 1s 每次重试的基础等待间隔(按指数退避翻倍)
StartupCheckDatabaseExistsMaxDelay TimeSpan 1min 单次重试等待间隔上限

兼容模式 SQL 方言

不同兼容模式下,SQL 语法自动适配:

特性 Oracle/MySQL/TD/PG M-Compatibility
标识符引用 "schema"."table" `schema`.`table`
参数占位 @Param @Param
行锁 FOR UPDATE SKIP LOCKED FOR UPDATE
时间累加 "Col" + interval 'N' second date_add(col, interval N second)
小时聚合 to_char("Added", 'yyyy-MM-dd-HH') DATE_FORMAT(Added, '%Y-%m-%d-%H')
数据类型 TIMESTAMP / TEXT datetime / longtext

依赖


Product Compatible and additional computed target framework versions.
.NET 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 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

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
10.0.2 154 7/3/2026