Update SimpleClient.CopyNew()

This commit is contained in:
sunkaixuan
2023-05-28 21:42:15 +08:00
parent 405978ba63
commit 663750c4c3
3 changed files with 22 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ namespace SqlSugar
{
public interface ISimpleClient<T> where T : class, new()
{
ISqlSugarClient CopyNew();
SimpleClient<T> CopyNew();
RepositoryType CopyNew<RepositoryType>() where RepositoryType : ISugarRepository;
SimpleClient<ChangeType> Change<ChangeType>() where ChangeType : class, new();
RepositoryType ChangeRepository<RepositoryType>() where RepositoryType : ISugarRepository ;

View File

@@ -36,10 +36,11 @@ namespace SqlSugar
{
return this.Context.GetSimpleClient<ChangeType>();
}
public ISqlSugarClient CopyNew()
public SimpleClient<T> CopyNew()
{
this.Context = this.Context.CopyNew();
return this.Context;
SimpleClient<T> sm = new SimpleClient<T>();
sm.Context = this.Context.CopyNew();
return sm;
}
public RepositoryType CopyNew<RepositoryType>() where RepositoryType : ISugarRepository
{

View File

@@ -19,7 +19,15 @@ namespace SqlSugar
{
internal static void EndCustomSplitTable(ISqlSugarClient context,Type entityType)
{
if (context == null || entityType == null)
{
return;
}
var splitTableAttribute = entityType.GetCustomAttribute<SplitTableAttribute>();
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<SplitTableAttribute>();
if (splitTableAttribute == null)
{
return;
}
var splitTableAttribute = entityType.GetCustomAttribute<SplitTableAttribute>();
if (splitTableAttribute.CustomSplitTableService != null)
{