mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
-
This commit is contained in:
@@ -32,7 +32,7 @@ namespace OrmTest.Demo
|
|||||||
|
|
||||||
public static SqlSugarClient GetInstance()
|
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.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@@ -53,7 +53,7 @@ namespace OrmTest.Demo
|
|||||||
|
|
||||||
public static SqlSugarClient GetInstance()
|
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.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@@ -265,7 +265,7 @@ namespace OrmTest.Demo
|
|||||||
|
|
||||||
public static SqlSugarClient GetInstance()
|
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.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@@ -56,7 +56,7 @@ namespace OrmTest.Demo
|
|||||||
}
|
}
|
||||||
public static SqlSugarClient GetInstance()
|
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.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@@ -16,7 +16,7 @@ namespace OrmTest.PerformanceTesting
|
|||||||
}
|
}
|
||||||
public void Select()
|
public void Select()
|
||||||
{
|
{
|
||||||
SqlSugarClient db = new SqlSugarClient(new SystemTableConfig()
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
ConnectionString = Config.ConnectionString,
|
ConnectionString = Config.ConnectionString,
|
||||||
DbType = DbType.SqlServer,
|
DbType = DbType.SqlServer,
|
||||||
|
@@ -55,7 +55,7 @@ namespace OrmTest
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ new List<SugarParameter>() {
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ namespace OrmTest.UnitTest
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ namespace OrmTest.UnitTest
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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.IsEnableLogEvent = true;
|
||||||
db.Ado.LogEventStarting = (sql, pars) =>
|
db.Ado.LogEventStarting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
|
@@ -87,7 +87,7 @@ namespace OrmTest.UnitTest
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ namespace OrmTest.UnitTest
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@ namespace OrmTest.UnitTest
|
|||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ namespace OrmTest.UnitTest
|
|||||||
{
|
{
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ namespace OrmTest.UnitTest
|
|||||||
}
|
}
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,7 +128,7 @@ UNION ALL
|
|||||||
|
|
||||||
public SqlSugarClient GetInstance()
|
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;
|
return db;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,8 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public IDbTransaction Transaction { get; set; }
|
public IDbTransaction Transaction { get; set; }
|
||||||
public virtual SqlSugarClient Context { get; set; }
|
public virtual SqlSugarClient Context { get; set; }
|
||||||
public virtual IConnectionConfig MasterConnectionConfig { get; set; }
|
public virtual ConnectionConfig MasterConnectionConfig { get; set; }
|
||||||
public virtual List<IConnectionConfig> SlaveConnectionConfigs { get; set; }
|
public virtual List<ConnectionConfig> SlaveConnectionConfigs { get; set; }
|
||||||
public virtual IDbBind DbBind
|
public virtual IDbBind DbBind
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@@ -12,7 +12,7 @@ namespace SqlSugar
|
|||||||
throw new SqlSugarException("SqlSugarException.NotSupportedException:" + message);
|
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())
|
if (config == null || config.ConnectionString.IsNullOrEmpty() || config.DbType.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
@@ -5,17 +5,34 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class SystemTableConfig : IConnectionConfig
|
public class ConnectionConfig
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
///DbType.SqlServer Or Other
|
||||||
|
/// </summary>
|
||||||
public string DbType { get; set; }
|
public string DbType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///Database Connection string
|
||||||
|
/// </summary>
|
||||||
public string ConnectionString { get; set; }
|
public string ConnectionString { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// true does not need to close the connection
|
||||||
|
/// </summary>
|
||||||
public bool IsAutoCloseConnection { get; set; }
|
public bool IsAutoCloseConnection { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Default SystemTable,If you do not have system table permissions, use attribute
|
||||||
|
/// </summary>
|
||||||
|
public InitKeyType InitKeyType = InitKeyType.SystemTable;
|
||||||
}
|
}
|
||||||
|
public enum InitKeyType
|
||||||
public class AttributeConfig : IConnectionConfig
|
|
||||||
{
|
{
|
||||||
public string DbType { get; set; }
|
/// <summary>
|
||||||
public string ConnectionString { get; set; }
|
/// Init primary key and identity key from the system table
|
||||||
public bool IsAutoCloseConnection { get; set; }
|
/// </summary>
|
||||||
|
SystemTable = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Init primary key and identity key from the attribute
|
||||||
|
/// </summary>
|
||||||
|
Attribute = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,65 +12,57 @@ namespace SqlSugar
|
|||||||
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
||||||
|
|
||||||
#region Queryable
|
#region Queryable
|
||||||
public static ISugarQueryable<T> GetQueryable<T>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T> GetQueryable<T>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T> reval = CreateInstance<T, ISugarQueryable<T>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T> reval = CreateInstance<T, ISugarQueryable<T>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2> GetQueryable<T, T2>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2> GetQueryable<T, T2>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2> reval = CreateInstance<T, T2, ISugarQueryable<T, T2>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2> reval = CreateInstance<T, T2, ISugarQueryable<T, T2>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3> GetQueryable<T, T2, T3>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3> GetQueryable<T, T2, T3>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3> reval = CreateInstance<T, T2, T3, ISugarQueryable<T, T2, T3>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3> reval = CreateInstance<T, T2, T3, ISugarQueryable<T, T2, T3>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4> GetQueryable<T, T2, T3, T4>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4> GetQueryable<T, T2, T3, T4>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3, T4> reval = CreateInstance<T, T2, T3, T4, ISugarQueryable<T, T2, T3, T4>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3, T4> reval = CreateInstance<T, T2, T3, T4, ISugarQueryable<T, T2, T3, T4>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5> GetQueryable<T, T2, T3, T4, T5>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5> GetQueryable<T, T2, T3, T4, T5>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5> reval = CreateInstance<T, T2, T3, T4, T5, ISugarQueryable<T, T2, T3, T4, T5>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3, T4, T5> reval = CreateInstance<T, T2, T3, T4, T5, ISugarQueryable<T, T2, T3, T4, T5>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6> GetQueryable<T, T2, T3, T4, T5, T6>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6> GetQueryable<T, T2, T3, T4, T5, T6>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6> reval = CreateInstance<T, T2, T3, T4, T5, T6, ISugarQueryable<T, T2, T3, T4, T5, T6>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3, T4, T5, T6> reval = CreateInstance<T, T2, T3, T4, T5, T6, ISugarQueryable<T, T2, T3, T4, T5, T6>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GetQueryable<T, T2, T3, T4, T5, T6, T7>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7> GetQueryable<T, T2, T3, T4, T5, T6, T7>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> reval = CreateInstance<T, T2, T3, T4, T5, T6, T7, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7> reval = CreateInstance<T, T2, T3, T4, T5, T6, T7, ISugarQueryable<T, T2, T3, T4, T5, T6, T7>>(className, currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(IConnectionConfig currentConnectionConfig)
|
public static ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> GetQueryable<T, T2, T3, T4, T5, T6, T7, T8>(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
string className = "Queryable";
|
string className = "Queryable";
|
||||||
className = GetClassName(currentConnectionConfig.DbType, className);
|
className = GetClassName(currentConnectionConfig.DbType, className);
|
||||||
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> reval = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>>(className, currentConnectionConfig.DbType);
|
ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> reval = CreateInstance<T, T2, T3, T4, T5, T6, T7, T8, ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8>>(className, currentConnectionConfig.DbType);
|
||||||
@@ -78,76 +70,65 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static QueryBuilder GetQueryBuilder(IConnectionConfig currentConnectionConfig)
|
public static QueryBuilder GetQueryBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
QueryBuilder reval = CreateInstance<QueryBuilder>(GetClassName(currentConnectionConfig.DbType, "QueryBuilder"), currentConnectionConfig.DbType);
|
QueryBuilder reval = CreateInstance<QueryBuilder>(GetClassName(currentConnectionConfig.DbType, "QueryBuilder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static InsertBuilder GetInsertBuilder(IConnectionConfig currentConnectionConfig)
|
public static InsertBuilder GetInsertBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
InsertBuilder reval = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType);
|
InsertBuilder reval = CreateInstance<InsertBuilder>(GetClassName(currentConnectionConfig.DbType, "InsertBuilder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static UpdateBuilder GetUpdateBuilder(IConnectionConfig currentConnectionConfig)
|
public static UpdateBuilder GetUpdateBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
UpdateBuilder reval = CreateInstance<UpdateBuilder>(GetClassName(currentConnectionConfig.DbType, "UpdateBuilder"), currentConnectionConfig.DbType);
|
UpdateBuilder reval = CreateInstance<UpdateBuilder>(GetClassName(currentConnectionConfig.DbType, "UpdateBuilder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
public static DeleteBuilder GetDeleteBuilder(IConnectionConfig currentConnectionConfig)
|
public static DeleteBuilder GetDeleteBuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
DeleteBuilder reval = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"), currentConnectionConfig.DbType);
|
DeleteBuilder reval = CreateInstance<DeleteBuilder>(GetClassName(currentConnectionConfig.DbType, "DeleteBuilder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ILambdaExpressions GetLambdaExpressions(IConnectionConfig currentConnectionConfig)
|
public static ILambdaExpressions GetLambdaExpressions(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
ILambdaExpressions reval = CreateInstance<ILambdaExpressions>(GetClassName(currentConnectionConfig.DbType, "ExpressionContext"), currentConnectionConfig.DbType);
|
ILambdaExpressions reval = CreateInstance<ILambdaExpressions>(GetClassName(currentConnectionConfig.DbType, "ExpressionContext"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ISqlBuilder GetSqlbuilder(IConnectionConfig currentConnectionConfig)
|
public static ISqlBuilder GetSqlbuilder(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
ISqlBuilder reval = CreateInstance<ISqlBuilder>(GetClassName(currentConnectionConfig.DbType, "Builder"), currentConnectionConfig.DbType);
|
ISqlBuilder reval = CreateInstance<ISqlBuilder>(GetClassName(currentConnectionConfig.DbType, "Builder"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbBind GetDbBind(IConnectionConfig currentConnectionConfig)
|
public static IDbBind GetDbBind(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
IDbBind reval = CreateInstance<IDbBind>(GetClassName(currentConnectionConfig.DbType, "DbBind"), currentConnectionConfig.DbType);
|
IDbBind reval = CreateInstance<IDbBind>(GetClassName(currentConnectionConfig.DbType, "DbBind"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbMaintenance GetDbMaintenance(IConnectionConfig currentConnectionConfig)
|
public static IDbMaintenance GetDbMaintenance(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
IDbMaintenance reval = CreateInstance<IDbMaintenance>(GetClassName(currentConnectionConfig.DbType, "DbMaintenance"), currentConnectionConfig.DbType);
|
IDbMaintenance reval = CreateInstance<IDbMaintenance>(GetClassName(currentConnectionConfig.DbType, "DbMaintenance"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IDbFirst GetDbFirst(IConnectionConfig currentConnectionConfig)
|
public static IDbFirst GetDbFirst(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
IDbFirst reval = CreateInstance<IDbFirst>(GetClassName(currentConnectionConfig.DbType, "DbFirst"), currentConnectionConfig.DbType);
|
IDbFirst reval = CreateInstance<IDbFirst>(GetClassName(currentConnectionConfig.DbType, "DbFirst"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICodeFirst GetCodeFirst(IConnectionConfig currentConnectionConfig)
|
public static ICodeFirst GetCodeFirst(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
ICodeFirst reval = CreateInstance<ICodeFirst>(GetClassName(currentConnectionConfig.DbType, "CodeFirst"), currentConnectionConfig.DbType);
|
ICodeFirst reval = CreateInstance<ICodeFirst>(GetClassName(currentConnectionConfig.DbType, "CodeFirst"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IAdo GetAdo(IConnectionConfig currentConnectionConfig)
|
public static IAdo GetAdo(ConnectionConfig currentConnectionConfig)
|
||||||
{
|
{
|
||||||
CheckConfig(currentConnectionConfig);
|
|
||||||
IAdo reval = CreateInstance<IAdo>(GetClassName(currentConnectionConfig.DbType, "Provider"), currentConnectionConfig.DbType);
|
IAdo reval = CreateInstance<IAdo>(GetClassName(currentConnectionConfig.DbType, "Provider"), currentConnectionConfig.DbType);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
@@ -365,11 +346,5 @@ namespace SqlSugar
|
|||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static void CheckConfig(IConnectionConfig currentConnectionConfig)
|
|
||||||
{
|
|
||||||
Check.ArgumentNullException(currentConnectionConfig, ErrorMessage.ConnectionConfigIsNull);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,8 +19,8 @@ namespace SqlSugar
|
|||||||
SqlSugarClient Context { get; set; }
|
SqlSugarClient Context { get; set; }
|
||||||
void ExecLogEvent(string sql, SugarParameter[] pars, bool isStarting = true);
|
void ExecLogEvent(string sql, SugarParameter[] pars, bool isStarting = true);
|
||||||
|
|
||||||
IConnectionConfig MasterConnectionConfig { get; set; }
|
ConnectionConfig MasterConnectionConfig { get; set; }
|
||||||
List<IConnectionConfig> SlaveConnectionConfigs { get; set; }
|
List<ConnectionConfig> SlaveConnectionConfigs { get; set; }
|
||||||
|
|
||||||
CommandType CommandType { get; set; }
|
CommandType CommandType { get; set; }
|
||||||
bool IsEnableLogEvent { get; set; }
|
bool IsEnableLogEvent { get; set; }
|
||||||
|
@@ -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; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -62,7 +62,6 @@
|
|||||||
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
|
||||||
<Compile Include="Abstract\UpdateProvider\UpdateableProvider.cs" />
|
<Compile Include="Abstract\UpdateProvider\UpdateableProvider.cs" />
|
||||||
<Compile Include="Entities\SugarMessageResult.cs" />
|
<Compile Include="Entities\SugarMessageResult.cs" />
|
||||||
<Compile Include="Interface\IConnectionConfig.cs" />
|
|
||||||
<Compile Include="Realization\MySql\DbType.cs" />
|
<Compile Include="Realization\MySql\DbType.cs" />
|
||||||
<Compile Include="Realization\MySql\Core\DbBind\MySqlDbBind.cs" />
|
<Compile Include="Realization\MySql\Core\DbBind\MySqlDbBind.cs" />
|
||||||
<Compile Include="Realization\MySql\Core\SqlBuilder\MySqlBuilder.cs" />
|
<Compile Include="Realization\MySql\Core\SqlBuilder\MySqlBuilder.cs" />
|
||||||
|
@@ -12,7 +12,7 @@ namespace SqlSugar
|
|||||||
#region Properties
|
#region Properties
|
||||||
public SqlSugarClient Context { get; set; }
|
public SqlSugarClient Context { get; set; }
|
||||||
public string EntityNamespace { get; set; }
|
public string EntityNamespace { get; set; }
|
||||||
public IConnectionConfig CurrentConnectionConfig { get; set; }
|
public ConnectionConfig CurrentConnectionConfig { get; set; }
|
||||||
public Dictionary<string, object> TempItems { get; set; }
|
public Dictionary<string, object> TempItems { get; set; }
|
||||||
public Guid ContextID { get; set; }
|
public Guid ContextID { get; set; }
|
||||||
public MappingTableList MappingTables = new MappingTableList();
|
public MappingTableList MappingTables = new MappingTableList();
|
||||||
|
@@ -21,36 +21,24 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.CurrentConnectionConfig is SystemTableConfig;
|
return this.CurrentConnectionConfig.InitKeyType==InitKeyType.SystemTable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
/// <summary>
|
public SqlSugarClient(ConnectionConfig config)
|
||||||
/// If you have system table permissions, use this
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
public SqlSugarClient(SystemTableConfig config)
|
|
||||||
{
|
{
|
||||||
base.Context = this;
|
base.Context = this;
|
||||||
base.CurrentConnectionConfig = config;
|
base.CurrentConnectionConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If you do not have system table permissions, use this
|
/// Read / write mode
|
||||||
/// </summary>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
public SqlSugarClient(AttributeConfig config)
|
|
||||||
{
|
|
||||||
base.Context = this;
|
|
||||||
base.CurrentConnectionConfig = config;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Read / write mode. If you have system table permissions, use this
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="masterConnectionConfig"></param>
|
/// <param name="masterConnectionConfig"></param>
|
||||||
/// <param name="slaveConnectionConfigs"></param>
|
/// <param name="slaveConnectionConfigs"></param>
|
||||||
public SqlSugarClient(SystemTableConfig masterConnectionConfig, IConnectionConfig[] slaveConnectionConfigs)
|
public SqlSugarClient(ConnectionConfig masterConnectionConfig, ConnectionConfig[] slaveConnectionConfigs)
|
||||||
{
|
{
|
||||||
base.Context = this;
|
base.Context = this;
|
||||||
base.CurrentConnectionConfig = masterConnectionConfig;
|
base.CurrentConnectionConfig = masterConnectionConfig;
|
||||||
@@ -60,22 +48,6 @@ namespace SqlSugar
|
|||||||
db.MasterConnectionConfig = masterConnectionConfig;
|
db.MasterConnectionConfig = masterConnectionConfig;
|
||||||
db.SlaveConnectionConfigs = slaveConnectionConfigs.ToList();
|
db.SlaveConnectionConfigs = slaveConnectionConfigs.ToList();
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Read / write mode. If you do not have system table permissions, use this
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="masterConnectionConfig"></param>
|
|
||||||
/// <param name="slaveConnectionConfigs"></param>
|
|
||||||
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
|
#endregion
|
||||||
|
|
||||||
#region ADO Method
|
#region ADO Method
|
||||||
|
Reference in New Issue
Block a user