Просмотр исходного кода

!694 使用SqlSugar.ChangeRepository方法时,base.Context可能为null,需要赋值默认Context
* 使用SqlSugar.ChangeRepository方法时,base.Context可能为null,需要赋值默认Context

清子 3 лет назад
Родитель
Сommit
0248a57b1f
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarRepository.cs

+ 6 - 2
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarRepository.cs

@@ -1,4 +1,4 @@
-namespace Admin.NET.Core;
+namespace Admin.NET.Core;
 
 /// <summary>
 /// SqlSugar仓储类
@@ -20,7 +20,11 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
         }
 
         // 若实体贴有系统表特性,则返回默认的连接
-        if (typeof(T).IsDefined(typeof(SystemTableAttribute), false)) return;
+        if (typeof(T).IsDefined(typeof(SystemTableAttribute), false))
+        {
+            base.Context = iTenant.GetConnectionScope(SqlSugarConst.ConfigId);
+            return;
+        }
 
         // 若当前未登录或是默认租户Id,则返回默认的连接
         var tenantId = App.GetRequiredService<UserManager>().TenantId;