mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-29 19:56:43 +08:00
Synchronization code
This commit is contained in:
parent
77411f0285
commit
f00fb21d6f
@ -15,7 +15,21 @@ namespace SqlSugar
|
|||||||
public T[] UpdateObjects { get; set; }
|
public T[] UpdateObjects { get; set; }
|
||||||
|
|
||||||
public IEnumerable<SplitTableInfo> Tables { get; set; }
|
public IEnumerable<SplitTableInfo> Tables { get; set; }
|
||||||
|
public int ExecuteCommandWithOptLock(bool isThrowError = false)
|
||||||
|
{
|
||||||
|
List<GroupModel> groupModels;
|
||||||
|
int result;
|
||||||
|
GroupDataList(UpdateObjects, out groupModels, out result);
|
||||||
|
foreach (var item in groupModels.GroupBy(it => it.GroupName))
|
||||||
|
{
|
||||||
|
var addList = item.Select(it => it.Item).ToList();
|
||||||
|
result += this.Context.Updateable(addList)
|
||||||
|
.UpdateColumns(updateobj.UpdateBuilder.UpdateColumns?.ToArray())
|
||||||
|
.IgnoreColumns(this.updateobj.UpdateBuilder.IsNoUpdateNull, this.updateobj.UpdateBuilder.IsOffIdentity, this.updateobj.UpdateBuilder.IsNoUpdateDefaultValue)
|
||||||
|
.IgnoreColumns(GetIgnoreColumns()).AS(item.Key).ExecuteCommandWithOptLock(isThrowError);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
{
|
{
|
||||||
List<GroupModel> groupModels;
|
List<GroupModel> groupModels;
|
||||||
@ -48,6 +62,21 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public async Task<int> ExecuteCommandWithOptLockAsync(bool isThrowError = false)
|
||||||
|
{
|
||||||
|
List<GroupModel> groupModels;
|
||||||
|
int result;
|
||||||
|
GroupDataList(UpdateObjects, out groupModels, out result);
|
||||||
|
foreach (var item in groupModels.GroupBy(it => it.GroupName))
|
||||||
|
{
|
||||||
|
var addList = item.Select(it => it.Item).ToList();
|
||||||
|
result += await this.Context.Updateable(addList)
|
||||||
|
.UpdateColumns(updateobj.UpdateBuilder.UpdateColumns?.ToArray())
|
||||||
|
.IgnoreColumns(this.updateobj.UpdateBuilder.IsNoUpdateNull, this.updateobj.UpdateBuilder.IsOffIdentity, this.updateobj.UpdateBuilder.IsNoUpdateDefaultValue)
|
||||||
|
.IgnoreColumns(GetIgnoreColumns()).AS(item.Key).ExecuteCommandWithOptLockAsync(isThrowError);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
private string [] GetIgnoreColumns()
|
private string [] GetIgnoreColumns()
|
||||||
{
|
{
|
||||||
if (this.updateobj.UpdateBuilder.DbColumnInfoList.Any())
|
if (this.updateobj.UpdateBuilder.DbColumnInfoList.Any())
|
||||||
|
Loading…
Reference in New Issue
Block a user