From 0d2368eb6719a681909aed71f4617c00b4b13b57 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 7 May 2019 08:28:56 +0800 Subject: [PATCH] Beautification code --- Src/Asp.Net/SqlSugar/SqlSugarClient.cs | 42 ++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 694328a04..b254e405b 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -24,7 +24,7 @@ namespace SqlSugar #endregion - #region Api + public ISqlSugarClient Context { get => GetContext(); set => _Context = value; } public SqlSugarClient(ConnectionConfig config) { @@ -149,10 +149,6 @@ namespace SqlSugar return this.Context.Deleteable(deleteObj); } - public void Dispose() - { - this.Context.Dispose(); - } public DateTime GetDate() { @@ -178,6 +174,7 @@ namespace SqlSugar this.Context.InitMppingInfo(typeof(T)); } + #region Insertable public IInsertable Insertable(Dictionary columnDictionary) where T : class, new() { return this.Context.Insertable(columnDictionary); @@ -203,11 +200,17 @@ namespace SqlSugar return this.Context.Insertable(insertObjs); } + #endregion public void Open() { this.Context.Open(); } + #region Queryable + public ISugarQueryable SqlQueryable(string sql) where T : class, new() + { + return this.Context.SqlQueryable(sql); + } public ISugarQueryable Queryable(string tableName, string shortName) { return this.Context.Queryable(tableName, shortName); @@ -407,6 +410,9 @@ namespace SqlSugar return this.Context.Queryable(shortName); } + #endregion + + #region Saveable public ISaveable Saveable(List saveObjects) where T : class, new() { return this.Context.Saveable(saveObjects); @@ -416,7 +422,9 @@ namespace SqlSugar { return this.Context.Saveable(saveObject); } + #endregion + #region Queue public int SaveQueues(bool isTran = true) { return this.Context.SaveQueues(isTran); @@ -495,13 +503,10 @@ namespace SqlSugar public Task> SaveQueuesAsync(bool isTran = true) { return this.Context.SaveQueuesAsync(isTran); - } - - public ISugarQueryable SqlQueryable(string sql) where T : class, new() - { - return this.Context.SqlQueryable(sql); - } + } + #endregion + #region Union public ISugarQueryable Union(List> queryables) where T : class, new() { return this.Context.Union(queryables); @@ -520,8 +525,10 @@ namespace SqlSugar public ISugarQueryable UnionAll(params ISugarQueryable[] queryables) where T : class, new() { return this.Context.UnionAll(queryables); - } + } + #endregion + #region Updateable public IUpdateable Updateable() where T : class, new() { return this.Context.Updateable(); @@ -562,6 +569,9 @@ namespace SqlSugar return this.Context.Updateable(UpdateObjs); } + #endregion + + #region ITenant public void BeginAllTran() { _IsAllTran = true; @@ -592,6 +602,14 @@ namespace SqlSugar } #endregion + #region IDispose + public void Dispose() + { + this.Context.Dispose(); + } + + #endregion + #region Helper private ISqlSugarClient GetContext() {