From d7f48e05376996eead7b4ddf592aa07db19eb096 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Sun, 27 Jul 2025 12:46:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Bfix:=20#ICP1R9=20=E5=BD=93=E6=9C=89?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E7=A7=9F=E6=88=B7=E6=97=B6=EF=BC=8C=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=A7=9F=E6=88=B7=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.WebApi/Startup.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenAuth.WebApi/Startup.cs b/OpenAuth.WebApi/Startup.cs index d50cb7a7..c7eedc08 100644 --- a/OpenAuth.WebApi/Startup.cs +++ b/OpenAuth.WebApi/Startup.cs @@ -187,6 +187,15 @@ namespace OpenAuth.WebApi connectionConfigs.Add(config); logger.LogInformation($"添加数据库连接: {conn.Key} / {(dbtypes.ContainsKey(conn.Key) ? dbtypes[conn.Key] : "未指定类型")},连接字符串:{conn.Value}"); } + + //通过ConfigId为空判断是否有默认的连接字符串 + if(!connectionConfigs.Any(x => x.ConfigId == null)) + { + throw new Exception($"没有找到默认的连接字符串:{Define.DEFAULT_TENANT_ID}"); + } + + //把connectionConfigs排序,ConfigId为空的放在最前面,即默认的连接字符串必须排最前面 + connectionConfigs = connectionConfigs.OrderBy(x => x.ConfigId == null ? 0 : 1).ToList(); var sqlSugar = new SqlSugarClient(connectionConfigs);