From a69b8c00265960f79b5bd20e010f4d6ea0078665 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Wed, 19 Oct 2022 14:20:53 +0800 Subject: [PATCH] Synchronization code --- .../SugarProvider/SqlSugarScopeProvider.cs | 2 +- .../Provider/Common/JsonCommonProvider.cs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs index 12cddc58b..3eb631a1b 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs @@ -12,7 +12,7 @@ namespace SqlSugar { public class SqlSugarScopeProvider:ISqlSugarClient { - private SqlSugarProvider conn; + internal SqlSugarProvider conn; public SqlSugarScopeProvider(SqlSugarProvider conn) { diff --git a/Src/Asp.Net/SqlSugar/Json2Sql/Provider/Common/JsonCommonProvider.cs b/Src/Asp.Net/SqlSugar/Json2Sql/Provider/Common/JsonCommonProvider.cs index abbf92fa8..5dd9bc3bf 100644 --- a/Src/Asp.Net/SqlSugar/Json2Sql/Provider/Common/JsonCommonProvider.cs +++ b/Src/Asp.Net/SqlSugar/Json2Sql/Provider/Common/JsonCommonProvider.cs @@ -11,7 +11,22 @@ namespace SqlSugar { //this.context = context; this.sqlBuilder = InstanceFactory.GetSqlbuilder(context.CurrentConnectionConfig); - this.sqlBuilder.Context = (context as SqlSugarClient).Context; + if (context is SqlSugarProvider) + { + this.sqlBuilder.Context = context as SqlSugarProvider; + } + else if (context is SqlSugarScopeProvider) + { + this.sqlBuilder.Context = (context as SqlSugarScopeProvider).conn; + } + else if(context is SqlSugarScope) + { + this.sqlBuilder.Context = (context as SqlSugarScope).GetConnection(context.CurrentConnectionConfig.ConfigId); + } + else + { + this.sqlBuilder.Context = (context as SqlSugarClient).Context; + } } //public ISqlSugarClient context { get; set; } public ISqlBuilder sqlBuilder { get; set; }