From 2ac87a14235bd5b5837fb80863052c456fb99e9c Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Fri, 17 Nov 2023 01:44:12 +0800
Subject: [PATCH] Support aot
---
.../SqlSugar/Entities/ConnectionConfig.cs | 2 +-
Src/Asp.NetCore2/SqlSugar/Interface/ITenant.cs | 10 +++++-----
Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs | 14 +++++++-------
Src/Asp.NetCore2/SqlSugar/SqlSugarScope.cs | 8 ++++----
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/Src/Asp.NetCore2/SqlSugar/Entities/ConnectionConfig.cs b/Src/Asp.NetCore2/SqlSugar/Entities/ConnectionConfig.cs
index 549efd813..4d22d31f6 100644
--- a/Src/Asp.NetCore2/SqlSugar/Entities/ConnectionConfig.cs
+++ b/Src/Asp.NetCore2/SqlSugar/Entities/ConnectionConfig.cs
@@ -13,7 +13,7 @@ namespace SqlSugar
///
///Connection unique code
///
- public dynamic ConfigId { get; set; }
+ public object ConfigId { get; set; }
///
///DbType.SqlServer Or Other
///
diff --git a/Src/Asp.NetCore2/SqlSugar/Interface/ITenant.cs b/Src/Asp.NetCore2/SqlSugar/Interface/ITenant.cs
index 059575dfe..e8d9649ad 100644
--- a/Src/Asp.NetCore2/SqlSugar/Interface/ITenant.cs
+++ b/Src/Asp.NetCore2/SqlSugar/Interface/ITenant.cs
@@ -17,7 +17,7 @@ namespace SqlSugar
Task BeginTranAsync(IsolationLevel iso);
Task CommitTranAsync();
Task RollbackTranAsync();
- void ChangeDatabase(dynamic configId);
+ void ChangeDatabase(object configId);
void ChangeDatabase(Func changeExpression);
SqlSugarTransaction UseTran();
DbResult UseTran(Action action, Action errorCallBack = null);
@@ -26,9 +26,9 @@ namespace SqlSugar
Task> UseTranAsync(Func> action, Action errorCallBack = null);
void AddConnection(ConnectionConfig connection);
- SqlSugarProvider GetConnection(dynamic configId);
- void RemoveConnection(dynamic configId);
- SqlSugarScopeProvider GetConnectionScope(dynamic configId);
+ SqlSugarProvider GetConnection(object configId);
+ void RemoveConnection(object configId);
+ SqlSugarScopeProvider GetConnectionScope(object configId);
SqlSugarProvider GetConnectionWithAttr();
SqlSugarScopeProvider GetConnectionScopeWithAttr();
ISugarQueryable QueryableWithAttr();
@@ -41,7 +41,7 @@ namespace SqlSugar
IDeleteable DeleteableWithAttr(List deleteObjs) where T : class, new();
IDeleteable DeleteableWithAttr() where T : class, new();
- bool IsAnyConnection(dynamic configId);
+ bool IsAnyConnection(object configId);
void Close();
void Open();
diff --git a/Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs b/Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs
index 9ca204ade..5caeafec1 100644
--- a/Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs
+++ b/Src/Asp.NetCore2/SqlSugar/SqlSugarClient.cs
@@ -903,13 +903,13 @@ namespace SqlSugar
var configId = attr.configId;
return this.GetConnectionScope(configId);
}
- public SqlSugarProvider GetConnection(dynamic configId)
+ public SqlSugarProvider GetConnection(object configId)
{
InitTenant();
var db = this._AllClients.FirstOrDefault(it =>Convert.ToString(it.ConnectionConfig.ConfigId) ==Convert.ToString(configId));
if (db == null)
{
- Check.Exception(true, "ConfigId was not found {0}", configId);
+ Check.Exception(true, "ConfigId was not found {0}", configId+"");
}
if (db.Context == null)
{
@@ -932,24 +932,24 @@ namespace SqlSugar
return db.Context;
}
- public SqlSugarScopeProvider GetConnectionScope(dynamic configId)
+ public SqlSugarScopeProvider GetConnectionScope(object configId)
{
var conn = GetConnection(configId);
return new SqlSugarScopeProvider(conn);
}
- public bool IsAnyConnection(dynamic configId)
+ public bool IsAnyConnection(object configId)
{
InitTenant();
var db = this._AllClients.FirstOrDefault(it => Convert.ToString(it.ConnectionConfig.ConfigId) == Convert.ToString(configId));
return db != null;
}
- public void ChangeDatabase(dynamic configId)
+ public void ChangeDatabase(object configId)
{
configId =Convert.ToString(configId);
var isLog = _Context.Ado.IsEnableLogEvent;
- Check.Exception(!_AllClients.Any(it =>Convert.ToString( it.ConnectionConfig.ConfigId) == configId), "ConfigId was not found {0}", configId);
- InitTenant(_AllClients.First(it => Convert.ToString(it.ConnectionConfig.ConfigId )== configId));
+ Check.Exception(!_AllClients.Any(it =>Convert.ToString( it.ConnectionConfig.ConfigId) ==Convert.ToString( configId)), "ConfigId was not found {0}", configId+"");
+ InitTenant(_AllClients.First(it => Convert.ToString(it.ConnectionConfig.ConfigId )==Convert.ToString( configId)));
if (this._IsAllTran)
this.Ado.BeginTran();
if (this._IsOpen)
diff --git a/Src/Asp.NetCore2/SqlSugar/SqlSugarScope.cs b/Src/Asp.NetCore2/SqlSugar/SqlSugarScope.cs
index eb41f16b2..4304c9c64 100644
--- a/Src/Asp.NetCore2/SqlSugar/SqlSugarScope.cs
+++ b/Src/Asp.NetCore2/SqlSugar/SqlSugarScope.cs
@@ -105,7 +105,7 @@ namespace SqlSugar
{
await ScopedContext.BeginTranAsync(iso);
}
- public void ChangeDatabase(dynamic configId)
+ public void ChangeDatabase(object configId)
{
ScopedContext.ChangeDatabase(configId);
}
@@ -172,11 +172,11 @@ namespace SqlSugar
ScopedContext.Dispose();
}
- public SqlSugarProvider GetConnection(dynamic configId)
+ public SqlSugarProvider GetConnection(object configId)
{
return ScopedContext.GetConnection(configId);
}
- public SqlSugarScopeProvider GetConnectionScope(dynamic configId)
+ public SqlSugarScopeProvider GetConnectionScope(object configId)
{
return ScopedContext.GetConnectionScope(configId);
}
@@ -733,7 +733,7 @@ namespace SqlSugar
return ScopedContext.UseTranAsync(action, errorCallBack);
}
- public bool IsAnyConnection(dynamic configId)
+ public bool IsAnyConnection(object configId)
{
return ScopedContext.IsAnyConnection(configId);
}