Update SqlSugraScopProvider

This commit is contained in:
sunkaixuan
2023-01-09 20:34:34 +08:00
parent be5cd3a940
commit 842284ae4a

View File

@@ -13,6 +13,7 @@ namespace SqlSugar
public class SqlSugarScopeProvider:ISqlSugarClient
{
internal SqlSugarProvider conn;
StackFrame[] frames;
public SqlSugarScopeProvider(SqlSugarProvider conn)
{
@@ -89,10 +90,13 @@ namespace SqlSugar
private dynamic GetKey()
{
var key= "SqlSugarProviderScope_" + conn.CurrentConnectionConfig.ConfigId;
var methods= new StackTrace(true).GetFrames();
if (methods.Length >= 0)
if (frames == null)
{
foreach (var method in methods.Take(10))
frames = new StackTrace(true).GetFrames();
}
if (frames.Length >= 0)
{
foreach (var method in frames.Take(10))
{
var getInterfaces = method.GetMethod()?.ReflectedType?.GetInterfaces();
if (getInterfaces != null && getInterfaces.Any(it => it.Name.IsIn("IJob", "IHostedService")))