From 9e76b7e993b03e233e1f2f131ef3947f2d5f234d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 3 Feb 2023 02:54:54 +0800 Subject: [PATCH] Update ExecuteReturnSnowflakeId --- .../InsertableProvider/InsertableProvider.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index 64646d3ce..672d2c36c 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs @@ -181,6 +181,7 @@ namespace SqlSugar foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it=>it.PropertyName==snowProperty.PropertyName)) { item.Value = id; + snowProperty?.PropertyInfo.SetValue(this.InsertObjs.First(), id); } this.ExecuteCommand(); return id; @@ -197,6 +198,11 @@ namespace SqlSugar var id = SnowFlakeSingle.instance.getID(); item.Value = id; result.Add(id); + var obj = this.InsertObjs.ElementAtOrDefault(item.TableId); + if (obj != null) + { + snowProperty?.PropertyInfo.SetValue(obj, id); + } } this.ExecuteCommand(); return result; @@ -211,6 +217,7 @@ namespace SqlSugar foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it => it.PropertyName == snowProperty.PropertyName)) { item.Value = id; + snowProperty?.PropertyInfo.SetValue(this.InsertObjs.First(), id); } await this.ExecuteCommandAsync(); return id; @@ -227,6 +234,11 @@ namespace SqlSugar var id = SnowFlakeSingle.instance.getID(); item.Value = id; result.Add(id); + var obj = this.InsertObjs.ElementAtOrDefault(item.TableId); + if (obj != null) + { + snowProperty?.PropertyInfo.SetValue(obj, id); + } } await this.ExecuteCommandAsync(); return result;