Synchronization code

This commit is contained in:
sunkaixuan 2023-02-03 02:59:23 +08:00
parent 9e76b7e993
commit fff4605a24
2 changed files with 14 additions and 0 deletions

View File

@ -181,6 +181,7 @@ namespace SqlSugar
foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it=>it.PropertyName==snowProperty.PropertyName)) foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it=>it.PropertyName==snowProperty.PropertyName))
{ {
item.Value = id; item.Value = id;
snowProperty?.PropertyInfo.SetValue(this.InsertObjs.First(), id);
} }
this.ExecuteCommand(); this.ExecuteCommand();
return id; return id;
@ -197,6 +198,11 @@ namespace SqlSugar
var id = SnowFlakeSingle.instance.getID(); var id = SnowFlakeSingle.instance.getID();
item.Value = id; item.Value = id;
result.Add(id); result.Add(id);
var obj = this.InsertObjs.ElementAtOrDefault(item.TableId);
if (obj != null)
{
snowProperty?.PropertyInfo.SetValue(obj, id);
}
} }
this.ExecuteCommand(); this.ExecuteCommand();
return result; return result;
@ -211,6 +217,7 @@ namespace SqlSugar
foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it => it.PropertyName == snowProperty.PropertyName)) foreach (var item in this.InsertBuilder.DbColumnInfoList.Where(it => it.PropertyName == snowProperty.PropertyName))
{ {
item.Value = id; item.Value = id;
snowProperty?.PropertyInfo.SetValue(this.InsertObjs.First(), id);
} }
await this.ExecuteCommandAsync(); await this.ExecuteCommandAsync();
return id; return id;
@ -227,6 +234,11 @@ namespace SqlSugar
var id = SnowFlakeSingle.instance.getID(); var id = SnowFlakeSingle.instance.getID();
item.Value = id; item.Value = id;
result.Add(id); result.Add(id);
var obj = this.InsertObjs.ElementAtOrDefault(item.TableId);
if (obj != null)
{
snowProperty?.PropertyInfo.SetValue(obj, id);
}
} }
await this.ExecuteCommandAsync(); await this.ExecuteCommandAsync();
return result; return result;

View File

@ -901,6 +901,7 @@ namespace SqlSugar
public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new() public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
{ {
InitMappingInfo<T>(); InitMappingInfo<T>();
Check.ExceptionEasy(UpdateObjs is IList&&typeof(T).FullName.IsCollectionsList(), "The methods you encapsulate are loaded incorrectly, so List<T> should be Updateable<T>(List<T> UpdateObjs)where T: class, new()", "你封装的方法进错重载List<T>应该进Updateable<T>(List<T> UpdateObjs)where T : class, new()重载");
UpdateableProvider<T> result = this.CreateUpdateable(UpdateObjs); UpdateableProvider<T> result = this.CreateUpdateable(UpdateObjs);
return result; return result;
} }
@ -917,6 +918,7 @@ namespace SqlSugar
} }
public virtual IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new() public virtual IUpdateable<T> Updateable<T>(T UpdateObj) where T : class, new()
{ {
return this.Context.Updateable(new T[] { UpdateObj }); return this.Context.Updateable(new T[] { UpdateObj });
} }
public virtual IUpdateable<T> Updateable<T>() where T : class, new() public virtual IUpdateable<T> Updateable<T>() where T : class, new()