diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs index 64646d3ce..672d2c36c 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/InsertableProvider/InsertableProvider.cs +++ b/Src/Asp.NetCore2/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; diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs index 9f8c2ada1..338260c5f 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs @@ -901,6 +901,7 @@ namespace SqlSugar public virtual IUpdateable Updateable(T[] UpdateObjs) where T : class, new() { InitMappingInfo(); + Check.ExceptionEasy(UpdateObjs is IList&&typeof(T).FullName.IsCollectionsList(), "The methods you encapsulate are loaded incorrectly, so List should be Updateable(List UpdateObjs)where T: class, new()", "你封装的方法进错重载,List应该进Updateable(List UpdateObjs)where T : class, new()重载"); UpdateableProvider result = this.CreateUpdateable(UpdateObjs); return result; } @@ -917,6 +918,7 @@ namespace SqlSugar } public virtual IUpdateable Updateable(T UpdateObj) where T : class, new() { + return this.Context.Updateable(new T[] { UpdateObj }); } public virtual IUpdateable Updateable() where T : class, new()