mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-07 18:04:55 +08:00
code optimization
This commit is contained in:
@@ -1274,25 +1274,25 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual void ExecuteBefore(string sql, SugarParameter[] parameters)
|
public virtual void ExecuteBefore(string sql, SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
if (this.Context.CurrentConnectionConfig.Debugger != null && this.Context.CurrentConnectionConfig.Debugger.EnableThreadSecurityValidation == true)
|
//if (this.Context.CurrentConnectionConfig.Debugger != null && this.Context.CurrentConnectionConfig.Debugger.EnableThreadSecurityValidation == true)
|
||||||
{
|
//{
|
||||||
|
|
||||||
var contextId = this.Context.ContextID.ToString();
|
// var contextId = this.Context.ContextID.ToString();
|
||||||
var processId = Thread.CurrentThread.ManagedThreadId.ToString();
|
// var processId = Thread.CurrentThread.ManagedThreadId.ToString();
|
||||||
var cache = new ReflectionInoCacheService();
|
// var cache = new ReflectionInoCacheService();
|
||||||
if (!cache.ContainsKey<string>(contextId))
|
// if (!cache.ContainsKey<string>(contextId))
|
||||||
{
|
// {
|
||||||
cache.Add(contextId, processId);
|
// cache.Add(contextId, processId);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var cacheValue = cache.Get<string>(contextId);
|
// var cacheValue = cache.Get<string>(contextId);
|
||||||
if (processId != cacheValue)
|
// if (processId != cacheValue)
|
||||||
{
|
// {
|
||||||
throw new SqlSugarException(this.Context, ErrorMessage.GetThrowMessage("Detection of SqlSugarClient cross-threading usage,a thread needs a new one", "检测到声名的SqlSugarClient跨线程使用,请检查是否静态、是否单例、或者IOC配置错误引起的,保证一个线程new出一个对象 ,具本Sql:") + sql, parameters);
|
// throw new SqlSugarException(this.Context, ErrorMessage.GetThrowMessage("Detection of SqlSugarClient cross-threading usage,a thread needs a new one", "检测到声名的SqlSugarClient跨线程使用,请检查是否静态、是否单例、或者IOC配置错误引起的,保证一个线程new出一个对象 ,具本Sql:") + sql, parameters);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
this.BeforeTime = DateTime.Now;
|
this.BeforeTime = DateTime.Now;
|
||||||
if (this.IsEnableLogEvent)
|
if (this.IsEnableLogEvent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ namespace SqlSugar
|
|||||||
/// More Gobal Settings
|
/// More Gobal Settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ConnMoreSettings MoreSettings { get; set; }
|
public ConnMoreSettings MoreSettings { get; set; }
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// Used for debugging errors or BUG,Used for debugging, which has an impact on Performance
|
///// Used for debugging errors or BUG,Used for debugging, which has an impact on Performance
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public SugarDebugger Debugger { get; set; }
|
//public SugarDebugger Debugger { get; set; }
|
||||||
|
|
||||||
public string IndexSuffix { get; set; }
|
public string IndexSuffix { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user