mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update split table
This commit is contained in:
parent
7d9a026d94
commit
3e7f31ced5
@ -24,10 +24,12 @@ namespace SqlSugar
|
||||
foreach (var item in groupModels.GroupBy(it => it.GroupName))
|
||||
{
|
||||
var addList = item.Select(it => it.Item).ToList();
|
||||
result += this.Context.Updateable(addList).AS(item.Key).ExecuteCommand();
|
||||
result += this.Context.Updateable(addList).IgnoreColumns(GetIgnoreColumns()).AS(item.Key).ExecuteCommand();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<int> ExecuteCommandAsync()
|
||||
{
|
||||
List<GroupModel> groupModels;
|
||||
@ -36,11 +38,22 @@ namespace SqlSugar
|
||||
foreach (var item in groupModels.GroupBy(it => it.GroupName))
|
||||
{
|
||||
var addList = item.Select(it => it.Item).ToList();
|
||||
result +=await this.Context.Updateable(addList).AS(item.Key).ExecuteCommandAsync();
|
||||
result += await this.Context.Updateable(addList).IgnoreColumns(GetIgnoreColumns()).AS(item.Key).ExecuteCommandAsync();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private string [] GetIgnoreColumns()
|
||||
{
|
||||
if (this.updateobj.UpdateBuilder.DbColumnInfoList.Any())
|
||||
{
|
||||
var columns=this.updateobj.UpdateBuilder.DbColumnInfoList.Select(it => it.DbColumnName).Distinct().ToList();
|
||||
return this.Context.EntityMaintenance.GetEntityInfo<T>().Columns.Where(x => !columns.Any(y => y.EqualCase(x.DbColumnName))).Select(it => it.DbColumnName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private void GroupDataList(T[] datas, out List<GroupModel> groupModels, out int result)
|
||||
{
|
||||
var attribute = typeof(T).GetCustomAttribute<SplitTableAttribute>() as SplitTableAttribute;
|
||||
|
Loading…
Reference in New Issue
Block a user