Synchronization code

This commit is contained in:
sunkaixuan 2024-04-04 13:36:34 +08:00
parent a8da11a4b2
commit 74fc30ba80
2 changed files with 8 additions and 2 deletions

View File

@ -40,6 +40,7 @@ namespace SqlSugar
public List<DbTableInfo> GetTableInfoList(Func<DbType,string, string> getChangeSqlFunc)
{
var db=this.Context.CopyNew();
db.CurrentConnectionConfig.IsAutoCloseConnection = true;
db.Aop.OnExecutingChangeSql = (sql, pars) =>
{
sql= getChangeSqlFunc(this.Context.CurrentConnectionConfig.DbType, sql);
@ -66,6 +67,7 @@ namespace SqlSugar
public List<DbColumnInfo> GetColumnInfosByTableName(string tableName, Func<DbType, string, string> getChangeSqlFunc)
{
var db = this.Context.CopyNew();
db.CurrentConnectionConfig.IsAutoCloseConnection = true;
db.Aop.OnExecutingChangeSql = (sql, pars) =>
{
sql = getChangeSqlFunc(this.Context.CurrentConnectionConfig.DbType, sql);

View File

@ -214,11 +214,15 @@ namespace SqlSugar
this.Context.Ado.IsEnableLogEvent = false;
foreach (var item in TableNames.GroupBy(it=>it.Key).Select(it=>it).ToDictionary(it=>it.Key,it=>it.First().Value))
{
if (!this.Context.CopyNew().DbMaintenance.IsAnyTable(item.Key, false))
var newDb = this.Context.CopyNew();
newDb.CurrentConnectionConfig.IsAutoCloseConnection = true;
if (!newDb.DbMaintenance.IsAnyTable(item.Key, false))
{
lock (SplitLockObj)
{
if (!this.Context.CopyNew().DbMaintenance.IsAnyTable(item.Key, false))
var newDb2 = this.Context.CopyNew();
newDb2.CurrentConnectionConfig.IsAutoCloseConnection = true;
if (!newDb2.DbMaintenance.IsAnyTable(item.Key, false))
{
if (item.Value != null)
{