zuohuaijun 2 лет назад
Родитель
Сommit
da9e79e9b8

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

@@ -10,8 +10,9 @@ namespace Admin.NET.Core;
 /// <typeparam name="T"></typeparam>
 public class SqlSugarRepository<T> : SimpleClient<T> where T : class, new()
 {
-    public SqlSugarRepository(ITenant iTenant)
+    public SqlSugarRepository()
     {
+        var iTenant = App.GetRequiredService<ISqlSugarClient>().AsTenant();
         base.Context = iTenant.GetConnectionScope(SqlSugarConst.MainConfigId);
 
         // 若实体贴有多库特性,则返回指定库连接

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

@@ -41,7 +41,6 @@ public static class SqlSugarSetup
         });
 
         services.AddSingleton<ISqlSugarClient>(sqlSugar); // 单例注册
-        services.AddSingleton(sqlSugar.AsTenant()); // 多租户单例注册
         services.AddScoped(typeof(SqlSugarRepository<>)); // 仓储注册
         services.AddUnitOfWork<SqlSugarUnitOfWork>(); // 事务与工作单元注册