diff --git a/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs b/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs index 14093c056..573c033f4 100644 --- a/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs +++ b/Src/Asp.Net/SqlSugar/Interface/ISimpleClient.cs @@ -8,7 +8,7 @@ namespace SqlSugar { public interface ISimpleClient where T : class, new() { - ISqlSugarClient CopyNew(); + SimpleClient CopyNew(); RepositoryType CopyNew() where RepositoryType : ISugarRepository; SimpleClient Change() where ChangeType : class, new(); RepositoryType ChangeRepository() where RepositoryType : ISugarRepository ; diff --git a/Src/Asp.Net/SqlSugar/SimpleClient.cs b/Src/Asp.Net/SqlSugar/SimpleClient.cs index bb30d331d..0af7316d5 100644 --- a/Src/Asp.Net/SqlSugar/SimpleClient.cs +++ b/Src/Asp.Net/SqlSugar/SimpleClient.cs @@ -36,10 +36,11 @@ namespace SqlSugar { return this.Context.GetSimpleClient(); } - public ISqlSugarClient CopyNew() + public SimpleClient CopyNew() { - this.Context = this.Context.CopyNew(); - return this.Context; + SimpleClient sm = new SimpleClient(); + sm.Context = this.Context.CopyNew(); + return sm; } public RepositoryType CopyNew() where RepositoryType : ISugarRepository { diff --git a/Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs b/Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs index f36fa9526..aaf48c68f 100644 --- a/Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs +++ b/Src/Asp.NetCore2/SqlSugar/Utilities/UtilMethods.cs @@ -19,7 +19,15 @@ namespace SqlSugar { internal static void EndCustomSplitTable(ISqlSugarClient context,Type entityType) { + if (context == null || entityType == null) + { + return; + } var splitTableAttribute = entityType.GetCustomAttribute(); + if (splitTableAttribute == null) + { + return; + } if (splitTableAttribute.CustomSplitTableService != null) { context.CurrentConnectionConfig.ConfigureExternalServices.SplitTableService = null; @@ -28,6 +36,15 @@ namespace SqlSugar internal static void StartCustomSplitTable(ISqlSugarClient context, Type entityType) { + if (context == null || entityType == null) + { + return; + } + var splitTableAttribute = entityType.GetCustomAttribute(); + if (splitTableAttribute == null) + { + return; + } var splitTableAttribute = entityType.GetCustomAttribute(); if (splitTableAttribute.CustomSplitTableService != null) {