From 5d6601f8114821cf496c10beeb1b53e3584ebb48 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 28 May 2017 10:01:58 +0800 Subject: [PATCH] - --- SqlServerTest/Demo/Delete.cs | 2 +- SqlServerTest/Demo/Insert.cs | 2 +- SqlServerTest/Demo/Query.cs | 2 +- SqlServerTest/Demo/Update.cs | 2 +- .../PerformanceTesting/SqlSugarPerformance.cs | 2 +- SqlServerTest/UnitTest/Delete.cs | 2 +- SqlServerTest/UnitTest/Insert.cs | 2 +- SqlServerTest/UnitTest/Mapping .cs | 2 +- SqlServerTest/UnitTest/Query/JoinQuery.cs | 2 +- SqlServerTest/UnitTest/Query/SelectQuery.cs | 2 +- SqlServerTest/UnitTest/Query/SingleQuery.cs | 2 +- SqlServerTest/UnitTest/Setting/AutoClose.cs | 2 +- SqlServerTest/UnitTest/Setting/MapColumn.cs | 2 +- SqlServerTest/UnitTest/Setting/MapTable.cs | 2 +- SqlServerTest/UnitTest/Update.cs | 2 +- SqlSugar/Abstract/AdoProvider/AdoProvider.cs | 4 +- SqlSugar/Common/Check.cs | 2 +- SqlSugar/Entities/ConnectionConfig.cs | 29 +++++++-- SqlSugar/InstanceFactory.cs | 63 ++++++------------- SqlSugar/Interface/IAdo.cs | 4 +- SqlSugar/Interface/IConnectionConfig.cs | 15 ----- SqlSugar/SqlSugar.csproj | 1 - SqlSugar/SqlSugarAccessory.cs | 2 +- SqlSugar/SqlSugarClient.cs | 38 ++--------- 24 files changed, 68 insertions(+), 120 deletions(-) delete mode 100644 SqlSugar/Interface/IConnectionConfig.cs diff --git a/SqlServerTest/Demo/Delete.cs b/SqlServerTest/Demo/Delete.cs index 7bba81db2..ff8583a2c 100644 --- a/SqlServerTest/Demo/Delete.cs +++ b/SqlServerTest/Demo/Delete.cs @@ -32,7 +32,7 @@ namespace OrmTest.Demo public static SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { diff --git a/SqlServerTest/Demo/Insert.cs b/SqlServerTest/Demo/Insert.cs index 49e5578b0..dd724c45e 100644 --- a/SqlServerTest/Demo/Insert.cs +++ b/SqlServerTest/Demo/Insert.cs @@ -53,7 +53,7 @@ namespace OrmTest.Demo public static SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { diff --git a/SqlServerTest/Demo/Query.cs b/SqlServerTest/Demo/Query.cs index f960f1c3e..c2739ceab 100644 --- a/SqlServerTest/Demo/Query.cs +++ b/SqlServerTest/Demo/Query.cs @@ -265,7 +265,7 @@ namespace OrmTest.Demo public static SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig{ ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { diff --git a/SqlServerTest/Demo/Update.cs b/SqlServerTest/Demo/Update.cs index 07d3700ac..1bbe90130 100644 --- a/SqlServerTest/Demo/Update.cs +++ b/SqlServerTest/Demo/Update.cs @@ -56,7 +56,7 @@ namespace OrmTest.Demo } public static SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { diff --git a/SqlServerTest/PerformanceTesting/SqlSugarPerformance.cs b/SqlServerTest/PerformanceTesting/SqlSugarPerformance.cs index 18e77ff60..5299a8813 100644 --- a/SqlServerTest/PerformanceTesting/SqlSugarPerformance.cs +++ b/SqlServerTest/PerformanceTesting/SqlSugarPerformance.cs @@ -16,7 +16,7 @@ namespace OrmTest.PerformanceTesting } public void Select() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, diff --git a/SqlServerTest/UnitTest/Delete.cs b/SqlServerTest/UnitTest/Delete.cs index 04349b4c1..c98f5b7ee 100644 --- a/SqlServerTest/UnitTest/Delete.cs +++ b/SqlServerTest/UnitTest/Delete.cs @@ -55,7 +55,7 @@ namespace OrmTest public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlServerTest/UnitTest/Insert.cs b/SqlServerTest/UnitTest/Insert.cs index dd7b59915..0ccb5d3a0 100644 --- a/SqlServerTest/UnitTest/Insert.cs +++ b/SqlServerTest/UnitTest/Insert.cs @@ -119,7 +119,7 @@ new List() { public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlServerTest/UnitTest/Mapping .cs b/SqlServerTest/UnitTest/Mapping .cs index 53c2b2983..6a10ccc69 100644 --- a/SqlServerTest/UnitTest/Mapping .cs +++ b/SqlServerTest/UnitTest/Mapping .cs @@ -39,7 +39,7 @@ namespace OrmTest.UnitTest public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new AttributeConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() {InitKeyType=InitKeyType.Attribute, ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlServerTest/UnitTest/Query/JoinQuery.cs b/SqlServerTest/UnitTest/Query/JoinQuery.cs index fcb27362d..79716a62f 100644 --- a/SqlServerTest/UnitTest/Query/JoinQuery.cs +++ b/SqlServerTest/UnitTest/Query/JoinQuery.cs @@ -71,7 +71,7 @@ namespace OrmTest.UnitTest public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { diff --git a/SqlServerTest/UnitTest/Query/SelectQuery.cs b/SqlServerTest/UnitTest/Query/SelectQuery.cs index a53ca0655..d8167d9fc 100644 --- a/SqlServerTest/UnitTest/Query/SelectQuery.cs +++ b/SqlServerTest/UnitTest/Query/SelectQuery.cs @@ -87,7 +87,7 @@ namespace OrmTest.UnitTest public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); return db; } } diff --git a/SqlServerTest/UnitTest/Query/SingleQuery.cs b/SqlServerTest/UnitTest/Query/SingleQuery.cs index 108a88ee2..b44a75c32 100644 --- a/SqlServerTest/UnitTest/Query/SingleQuery.cs +++ b/SqlServerTest/UnitTest/Query/SingleQuery.cs @@ -116,7 +116,7 @@ namespace OrmTest.UnitTest public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); return db; } } diff --git a/SqlServerTest/UnitTest/Setting/AutoClose.cs b/SqlServerTest/UnitTest/Setting/AutoClose.cs index fc0431164..6a91503c1 100644 --- a/SqlServerTest/UnitTest/Setting/AutoClose.cs +++ b/SqlServerTest/UnitTest/Setting/AutoClose.cs @@ -29,7 +29,7 @@ namespace OrmTest.UnitTest } public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlServerTest/UnitTest/Setting/MapColumn.cs b/SqlServerTest/UnitTest/Setting/MapColumn.cs index ec5fae8a7..5b3301226 100644 --- a/SqlServerTest/UnitTest/Setting/MapColumn.cs +++ b/SqlServerTest/UnitTest/Setting/MapColumn.cs @@ -11,7 +11,7 @@ namespace OrmTest.UnitTest { public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer }); return db; } } diff --git a/SqlServerTest/UnitTest/Setting/MapTable.cs b/SqlServerTest/UnitTest/Setting/MapTable.cs index 0c87c2bf7..49eded9b0 100644 --- a/SqlServerTest/UnitTest/Setting/MapTable.cs +++ b/SqlServerTest/UnitTest/Setting/MapTable.cs @@ -25,7 +25,7 @@ namespace OrmTest.UnitTest } public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlServerTest/UnitTest/Update.cs b/SqlServerTest/UnitTest/Update.cs index 6da2f5477..76d00873a 100644 --- a/SqlServerTest/UnitTest/Update.cs +++ b/SqlServerTest/UnitTest/Update.cs @@ -128,7 +128,7 @@ UNION ALL public SqlSugarClient GetInstance() { - SqlSugarClient db = new SqlSugarClient(new SystemTableConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); + SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); return db; } } diff --git a/SqlSugar/Abstract/AdoProvider/AdoProvider.cs b/SqlSugar/Abstract/AdoProvider/AdoProvider.cs index ce6c57826..75e7b4773 100644 --- a/SqlSugar/Abstract/AdoProvider/AdoProvider.cs +++ b/SqlSugar/Abstract/AdoProvider/AdoProvider.cs @@ -26,8 +26,8 @@ namespace SqlSugar } public IDbTransaction Transaction { get; set; } public virtual SqlSugarClient Context { get; set; } - public virtual IConnectionConfig MasterConnectionConfig { get; set; } - public virtual List SlaveConnectionConfigs { get; set; } + public virtual ConnectionConfig MasterConnectionConfig { get; set; } + public virtual List SlaveConnectionConfigs { get; set; } public virtual IDbBind DbBind { get diff --git a/SqlSugar/Common/Check.cs b/SqlSugar/Common/Check.cs index fadc69882..c9fcf99be 100644 --- a/SqlSugar/Common/Check.cs +++ b/SqlSugar/Common/Check.cs @@ -12,7 +12,7 @@ namespace SqlSugar throw new SqlSugarException("SqlSugarException.NotSupportedException:" + message); } - public static void ConnectionConfig(IConnectionConfig config) + public static void ConnectionConfig(ConnectionConfig config) { if (config == null || config.ConnectionString.IsNullOrEmpty() || config.DbType.IsNullOrEmpty()) { diff --git a/SqlSugar/Entities/ConnectionConfig.cs b/SqlSugar/Entities/ConnectionConfig.cs index a66271b55..17871f971 100644 --- a/SqlSugar/Entities/ConnectionConfig.cs +++ b/SqlSugar/Entities/ConnectionConfig.cs @@ -5,17 +5,34 @@ using System.Text; using System.Threading.Tasks; namespace SqlSugar { - public class SystemTableConfig : IConnectionConfig + public class ConnectionConfig { + /// + ///DbType.SqlServer Or Other + /// public string DbType { get; set; } + /// + ///Database Connection string + /// public string ConnectionString { get; set; } + /// + /// true does not need to close the connection + /// public bool IsAutoCloseConnection { get; set; } + /// + /// Default SystemTable,If you do not have system table permissions, use attribute + /// + public InitKeyType InitKeyType = InitKeyType.SystemTable; } - - public class AttributeConfig : IConnectionConfig + public enum InitKeyType { - public string DbType { get; set; } - public string ConnectionString { get; set; } - public bool IsAutoCloseConnection { get; set; } + /// + /// Init primary key and identity key from the system table + /// + SystemTable = 0, + /// + /// Init primary key and identity key from the attribute + /// + Attribute = 1 } } diff --git a/SqlSugar/InstanceFactory.cs b/SqlSugar/InstanceFactory.cs index fb9dcda36..b7ad81f8d 100644 --- a/SqlSugar/InstanceFactory.cs +++ b/SqlSugar/InstanceFactory.cs @@ -12,65 +12,57 @@ namespace SqlSugar static Dictionary typeCache = new Dictionary(); #region Queryable - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); return reval; } - public static ISugarQueryable GetQueryable(IConnectionConfig currentConnectionConfig) + public static ISugarQueryable GetQueryable(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); string className = "Queryable"; className = GetClassName(currentConnectionConfig.DbType, className); ISugarQueryable reval = CreateInstance>(className, currentConnectionConfig.DbType); @@ -78,76 +70,65 @@ namespace SqlSugar } #endregion - public static QueryBuilder GetQueryBuilder(IConnectionConfig currentConnectionConfig) + public static QueryBuilder GetQueryBuilder(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); QueryBuilder reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "QueryBuilder"), currentConnectionConfig.DbType); return reval; } - public static InsertBuilder GetInsertBuilder(IConnectionConfig currentConnectionConfig) + public static InsertBuilder GetInsertBuilder(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); InsertBuilder reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType); return reval; } - public static UpdateBuilder GetUpdateBuilder(IConnectionConfig currentConnectionConfig) + public static UpdateBuilder GetUpdateBuilder(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); UpdateBuilder reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "UpdateBuilder"), currentConnectionConfig.DbType); return reval; } - public static DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig) + public static DeleteBuilder GetDeleteBuilder(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); DeleteBuilder reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"), currentConnectionConfig.DbType); return reval; } - public static ILambdaExpressions GetLambdaExpressions(IConnectionConfig currentConnectionConfig) + public static ILambdaExpressions GetLambdaExpressions(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); ILambdaExpressions reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "ExpressionContext"), currentConnectionConfig.DbType); return reval; } - public static ISqlBuilder GetSqlbuilder(IConnectionConfig currentConnectionConfig) + public static ISqlBuilder GetSqlbuilder(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); ISqlBuilder reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "Builder"), currentConnectionConfig.DbType); return reval; } - public static IDbBind GetDbBind(IConnectionConfig currentConnectionConfig) + public static IDbBind GetDbBind(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); IDbBind reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "DbBind"), currentConnectionConfig.DbType); return reval; } - public static IDbMaintenance GetDbMaintenance(IConnectionConfig currentConnectionConfig) + public static IDbMaintenance GetDbMaintenance(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); IDbMaintenance reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "DbMaintenance"), currentConnectionConfig.DbType); return reval; } - public static IDbFirst GetDbFirst(IConnectionConfig currentConnectionConfig) + public static IDbFirst GetDbFirst(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); IDbFirst reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "DbFirst"), currentConnectionConfig.DbType); return reval; } - public static ICodeFirst GetCodeFirst(IConnectionConfig currentConnectionConfig) + public static ICodeFirst GetCodeFirst(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); ICodeFirst reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "CodeFirst"), currentConnectionConfig.DbType); return reval; } - public static IAdo GetAdo(IConnectionConfig currentConnectionConfig) + public static IAdo GetAdo(ConnectionConfig currentConnectionConfig) { - CheckConfig(currentConnectionConfig); IAdo reval = CreateInstance(GetClassName(currentConnectionConfig.DbType, "Provider"), currentConnectionConfig.DbType); return reval; } @@ -365,11 +346,5 @@ namespace SqlSugar return reval; } #endregion - - private static void CheckConfig(IConnectionConfig currentConnectionConfig) - { - Check.ArgumentNullException(currentConnectionConfig, ErrorMessage.ConnectionConfigIsNull); - } - } } diff --git a/SqlSugar/Interface/IAdo.cs b/SqlSugar/Interface/IAdo.cs index 32b2e3e5c..29dff2d85 100644 --- a/SqlSugar/Interface/IAdo.cs +++ b/SqlSugar/Interface/IAdo.cs @@ -19,8 +19,8 @@ namespace SqlSugar SqlSugarClient Context { get; set; } void ExecLogEvent(string sql, SugarParameter[] pars, bool isStarting = true); - IConnectionConfig MasterConnectionConfig { get; set; } - List SlaveConnectionConfigs { get; set; } + ConnectionConfig MasterConnectionConfig { get; set; } + List SlaveConnectionConfigs { get; set; } CommandType CommandType { get; set; } bool IsEnableLogEvent { get; set; } diff --git a/SqlSugar/Interface/IConnectionConfig.cs b/SqlSugar/Interface/IConnectionConfig.cs deleted file mode 100644 index de1063d7a..000000000 --- a/SqlSugar/Interface/IConnectionConfig.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SqlSugar -{ - public interface IConnectionConfig - { - string DbType { get; set; } - string ConnectionString { get; set; } - bool IsAutoCloseConnection { get; set; } - } - -} diff --git a/SqlSugar/SqlSugar.csproj b/SqlSugar/SqlSugar.csproj index a3abc2980..2628342d0 100644 --- a/SqlSugar/SqlSugar.csproj +++ b/SqlSugar/SqlSugar.csproj @@ -62,7 +62,6 @@ - diff --git a/SqlSugar/SqlSugarAccessory.cs b/SqlSugar/SqlSugarAccessory.cs index c537122c0..89a82f0a1 100644 --- a/SqlSugar/SqlSugarAccessory.cs +++ b/SqlSugar/SqlSugarAccessory.cs @@ -12,7 +12,7 @@ namespace SqlSugar #region Properties public SqlSugarClient Context { get; set; } public string EntityNamespace { get; set; } - public IConnectionConfig CurrentConnectionConfig { get; set; } + public ConnectionConfig CurrentConnectionConfig { get; set; } public Dictionary TempItems { get; set; } public Guid ContextID { get; set; } public MappingTableList MappingTables = new MappingTableList(); diff --git a/SqlSugar/SqlSugarClient.cs b/SqlSugar/SqlSugarClient.cs index 1de142bc6..2dcdf7717 100644 --- a/SqlSugar/SqlSugarClient.cs +++ b/SqlSugar/SqlSugarClient.cs @@ -21,36 +21,24 @@ namespace SqlSugar { get { - return this.CurrentConnectionConfig is SystemTableConfig; + return this.CurrentConnectionConfig.InitKeyType==InitKeyType.SystemTable; } } #endregion #region Constructor - /// - /// If you have system table permissions, use this - /// - /// - public SqlSugarClient(SystemTableConfig config) + public SqlSugarClient(ConnectionConfig config) { base.Context = this; base.CurrentConnectionConfig = config; } + /// - /// If you do not have system table permissions, use this - /// - /// - public SqlSugarClient(AttributeConfig config) - { - base.Context = this; - base.CurrentConnectionConfig = config; - } - /// - /// Read / write mode. If you have system table permissions, use this + /// Read / write mode /// /// /// - public SqlSugarClient(SystemTableConfig masterConnectionConfig, IConnectionConfig[] slaveConnectionConfigs) + public SqlSugarClient(ConnectionConfig masterConnectionConfig, ConnectionConfig[] slaveConnectionConfigs) { base.Context = this; base.CurrentConnectionConfig = masterConnectionConfig; @@ -60,22 +48,6 @@ namespace SqlSugar db.MasterConnectionConfig = masterConnectionConfig; db.SlaveConnectionConfigs = slaveConnectionConfigs.ToList(); } - /// - /// Read / write mode. If you do not have system table permissions, use this - /// - /// - /// - public SqlSugarClient(AttributeConfig masterConnectionConfig, IConnectionConfig[] slaveConnectionConfigs) - { - base.Context = this; - base.CurrentConnectionConfig = masterConnectionConfig; - if (slaveConnectionConfigs.IsNullOrEmpty()) return; - - var db = this.Ado; - db.MasterConnectionConfig = masterConnectionConfig; - db.SlaveConnectionConfigs = slaveConnectionConfigs.ToList(); - } - #endregion #region ADO Method