From 48dc89c43dfe69497d5715d48e827dc4112575fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Sat, 21 Dec 2024 15:04:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=AF=B9=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84guid=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YiFrameworkSqlSugarCoreModule.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs index 7cc138ac..4d83a783 100644 --- a/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs +++ b/Yi.Abp.Net8/framework/Yi.Framework.SqlSugarCore/YiFrameworkSqlSugarCoreModule.cs @@ -9,6 +9,7 @@ using SqlSugar; using Volo.Abp.Data; using Volo.Abp.Domain; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; using Yi.Framework.SqlSugarCore.Abstractions; using Yi.Framework.SqlSugarCore.Repositories; using Yi.Framework.SqlSugarCore.Uow; @@ -24,7 +25,32 @@ namespace Yi.Framework.SqlSugarCore var configuration = service.GetConfiguration(); var section = configuration.GetSection("DbConnOptions"); Configure(section); + var dbConnOptions = new DbConnOptions(); + section.Bind(dbConnOptions); + //很多人遗漏了这一点,不同的数据库,对于主键的使用规约不一样,需要根据数据库进行判断 + SequentialGuidType guidType; + switch (dbConnOptions.DbType) + { + case DbType.MySql: + case DbType.PostgreSQL: + guidType= SequentialGuidType.SequentialAsString; + break; + case DbType.SqlServer: + guidType = SequentialGuidType.SequentialAtEnd; + break; + case DbType.Oracle: + guidType = SequentialGuidType.SequentialAsBinary; + break; + default: + guidType = SequentialGuidType.SequentialAtEnd; + break; + } + Configure(options => + { + options.DefaultSequentialGuidType = guidType; + }); + service.TryAddScoped(); //不开放sqlsugarClient