diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs index def0e66e6..9f8aa7e3f 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs @@ -865,10 +865,7 @@ namespace SqlSugar var contextProperty = item.GetType().GetProperty("Context"); ConnectionConfig config = new ConnectionConfig(); config = this.Context.CurrentConnectionConfig; - var newClient = new SqlSugarClient(config); - newClient.MappingColumns = this.Context.MappingColumns; - newClient.MappingTables = this.Context.MappingTables; - newClient.IgnoreColumns = this.Context.IgnoreColumns; + SqlSugarClient newClient = this.Context.CopyContext(config); contextProperty.SetValue(item, newClient, null); } } diff --git a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs index 52ae2e438..f2be29e5b 100644 --- a/Src/Asp.Net/SqlSugar/SqlSugarClient.cs +++ b/Src/Asp.Net/SqlSugar/SqlSugarClient.cs @@ -565,6 +565,14 @@ namespace SqlSugar this.Ado.Dispose(); } } + internal SqlSugarClient CopyContext(ConnectionConfig config) + { + var newClient = new SqlSugarClient(config); + newClient.MappingColumns = this.Context.MappingColumns; + newClient.MappingTables = this.Context.MappingTables; + newClient.IgnoreColumns = this.Context.IgnoreColumns; + return newClient; + } #endregion } }