ソースを参照

😂恢复仓储记录处理

zuohuaijun 2 年 前
コミット
980ec37b79

+ 1 - 1
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarRepository.cs

@@ -12,7 +12,7 @@ public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
 {
     public SqlSugarRepository()
     {
-        var iTenant = SqlSugarSetup.ITenant;
+        var iTenant = App.GetRequiredService<ISqlSugarClient>().AsTenant();
         base.Context = iTenant.GetConnectionScope(SqlSugarConst.MainConfigId);
 
         // 若实体贴有多库特性,则返回指定库连接

+ 0 - 4
Admin.NET/Admin.NET.Core/SqlSugar/SqlSugarSetup.cs

@@ -6,9 +6,6 @@ namespace Admin.NET.Core;
 
 public static class SqlSugarSetup
 {
-    // 多租户实例
-    public static ITenant ITenant { get; set; }
-
     /// <summary>
     /// SqlSugar 上下文初始化
     /// </summary>
@@ -42,7 +39,6 @@ public static class SqlSugarSetup
                 SetDbDiffLog(dbProvider, config);
             });
         });
-        ITenant = sqlSugar.AsTenant();
 
         services.AddSingleton<ISqlSugarClient>(sqlSugar); // 单例注册
         services.AddScoped(typeof(SqlSugarRepository<>)); // 仓储注册