From 6f8eeaedb334b39a409554e8bfef0a10618fd52c Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 14 Oct 2023 21:13:38 +0800 Subject: [PATCH] Update split table create table --- .../Abstract/InsertableProvider/SplitInsertable.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs index c1b1e0d65..7e36e98ca 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/SplitInsertable.cs @@ -8,6 +8,7 @@ namespace SqlSugar { public class SplitInsertable where T:class ,new() { + private static readonly object SplitLockObj = new object(); public SqlSugarProvider Context; internal SplitTableContext Helper; public EntityInfo EntityInfo; @@ -215,10 +216,16 @@ namespace SqlSugar { if (!this.Context.DbMaintenance.IsAnyTable(item.Key, false)) { - if (item.Value != null) + lock (SplitLockObj) { - this.Context.MappingTables.Add(EntityInfo.EntityName, item.Key); - this.Context.CodeFirst.InitTables(); + if (!this.Context.DbMaintenance.IsAnyTable(item.Key, false)) + { + if (item.Value != null) + { + this.Context.MappingTables.Add(EntityInfo.EntityName, item.Key); + this.Context.CodeFirst.InitTables(); + } + } } } }