From 7e7f445a6f63604956f4bbb72b5ba438a0cf0818 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 15 Jun 2022 18:49:05 +0800 Subject: [PATCH] Add itenant api --- Src/Asp.Net/SqlSugar/Interface/ITenant.cs | 7 +++++ Src/Asp.Net/SqlSugar/SqlSugarClient.cs | 31 +++++++++++++++++++++++ Src/Asp.Net/SqlSugar/SqlSugarScope.cs | 28 ++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Interface/ITenant.cs b/Src/Asp.Net/SqlSugar/Interface/ITenant.cs index 84ed87555..3c0d09780 100644 --- a/Src/Asp.Net/SqlSugar/Interface/ITenant.cs +++ b/Src/Asp.Net/SqlSugar/Interface/ITenant.cs @@ -24,6 +24,13 @@ namespace SqlSugar SqlSugarScopeProvider GetConnectionScope(dynamic configId); SqlSugarProvider GetConnectionWithAttr(); SqlSugarScopeProvider GetConnectionScopeWithAttr(); + ISugarQueryable QueryableWithAttr(); + IInsertable InsertableWithAttr(T insertObj) where T : class, new(); + IInsertable InsertableWithAttr(List insertObjs) where T : class, new(); + IUpdateable UpdateableWithAttr(T updateObj) where T : class, new(); + IUpdateable UpdateableWithAttr(List updateObjs) where T : class, new(); + IDeleteable DeleteableWithAttr(T deleteObjs) where T : class, new(); + IDeleteable DeleteableWithAttr(List deleteObjs) where T : class, new(); bool IsAnyConnection(dynamic configId); void Close(); diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 488b71181..705928688 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -1243,5 +1243,36 @@ namespace SqlSugar this.CurrentConnectionConfig = Tenant.ConnectionConfig; } #endregion + + #region Tenant Crud + public ISugarQueryable QueryableWithAttr() + { + return this.GetConnectionWithAttr().Queryable(); + } + public IInsertable InsertableWithAttr(T insertObj) where T : class, new() + { + return this.GetConnectionWithAttr().Insertable(insertObj); + } + public IInsertable InsertableWithAttr(List insertObjs) where T : class, new() + { + return this.GetConnectionWithAttr().Insertable(insertObjs); + } + public IUpdateable UpdateableWithAttr(T updateObj) where T : class, new() + { + return this.GetConnectionWithAttr().Updateable(updateObj); + } + public IUpdateable UpdateableWithAttr(List updateObjs) where T : class, new() + { + return this.GetConnectionWithAttr().Updateable(updateObjs); + } + public IDeleteable DeleteableWithAttr(T deleteObject) where T : class, new() + { + return this.GetConnectionWithAttr().Deleteable(deleteObject); + } + public IDeleteable DeleteableWithAttr(List deleteObjects) where T : class, new() + { + return this.GetConnectionWithAttr().Deleteable(deleteObjects); + } + #endregion } } diff --git a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs index aad57c4a4..1a660cf34 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarScope.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarScope.cs @@ -695,5 +695,33 @@ namespace SqlSugar { return ScopedContext.ThenMapperAsync(list, action); } + public ISugarQueryable QueryableWithAttr() + { + return ScopedContext.QueryableWithAttr(); + } + public IInsertable InsertableWithAttr(T insertObj) where T : class, new() + { + return ScopedContext.InsertableWithAttr(insertObj); + } + public IInsertable InsertableWithAttr(List insertObjs) where T : class, new() + { + return ScopedContext.InsertableWithAttr(insertObjs); + } + public IUpdateable UpdateableWithAttr(T updateObj) where T : class, new() + { + return ScopedContext.UpdateableWithAttr(updateObj); + } + public IUpdateable UpdateableWithAttr(List updateObjs) where T : class, new() + { + return ScopedContext.UpdateableWithAttr(updateObjs); + } + public IDeleteable DeleteableWithAttr(T deleteObj) where T : class, new() + { + return ScopedContext.DeleteableWithAttr(deleteObj); + } + public IDeleteable DeleteableWithAttr(List deleteObjs) where T : class, new() + { + return ScopedContext.DeleteableWithAttr(deleteObjs); + } } }