mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
Split table
This commit is contained in:
parent
b5cff787de
commit
54e10e81f8
@ -57,7 +57,7 @@ namespace SqlSugar
|
|||||||
return await _ExecuteCommandAsync();
|
return await _ExecuteCommandAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int _ExecuteCommand()
|
internal int _ExecuteCommand()
|
||||||
{
|
{
|
||||||
var result = 0;
|
var result = 0;
|
||||||
var sqlobj = deleteobj.ToSql();
|
var sqlobj = deleteobj.ToSql();
|
||||||
@ -70,7 +70,7 @@ namespace SqlSugar
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> _ExecuteCommandAsync()
|
internal async Task<int> _ExecuteCommandAsync()
|
||||||
{
|
{
|
||||||
var result = 0;
|
var result = 0;
|
||||||
var sqlobj = deleteobj.ToSql();
|
var sqlobj = deleteobj.ToSql();
|
||||||
|
@ -16,6 +16,50 @@ namespace SqlSugar
|
|||||||
internal List<KeyValuePair<string,object>> TableNames { get; set; }
|
internal List<KeyValuePair<string,object>> TableNames { get; set; }
|
||||||
|
|
||||||
public int ExecuteCommand()
|
public int ExecuteCommand()
|
||||||
|
{
|
||||||
|
if (this.Context.Ado.Transaction == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.Context.Ado.BeginTran();
|
||||||
|
var result = _ExecuteCommand();
|
||||||
|
this.Context.Ado.CommitTran();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Context.Ado.RollbackTran();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task<int> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
if (this.Context.Ado.Transaction == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.Context.Ado.BeginTran();
|
||||||
|
var result = await _ExecuteCommandAsync();
|
||||||
|
this.Context.Ado.BeginTran();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Context.Ado.RollbackTran();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return await _ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal int _ExecuteCommand()
|
||||||
{
|
{
|
||||||
CreateTable();
|
CreateTable();
|
||||||
var result = 0;
|
var result = 0;
|
||||||
@ -36,7 +80,27 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
internal async Task<int> _ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
CreateTable();
|
||||||
|
var result = 0;
|
||||||
|
var groups = TableNames.GroupBy(it => it.Key).ToList();
|
||||||
|
var parent = ((InsertableProvider<T>)Inserable);
|
||||||
|
var names = parent.InsertBuilder.DbColumnInfoList.GroupBy(it => it.DbColumnName).Select(i => i.Key).ToList();
|
||||||
|
foreach (var item in groups)
|
||||||
|
{
|
||||||
|
var list = item.Select(it => it.Value as T).ToList();
|
||||||
|
var groupInserable = (InsertableProvider<T>)this.Context.Insertable<T>(list);
|
||||||
|
groupInserable.InsertBuilder.TableWithString = parent.InsertBuilder.TableWithString;
|
||||||
|
groupInserable.RemoveCacheFunc = parent.RemoveCacheFunc;
|
||||||
|
groupInserable.diffModel = parent.diffModel;
|
||||||
|
groupInserable.IsEnableDiffLogEvent = parent.IsEnableDiffLogEvent;
|
||||||
|
groupInserable.InsertBuilder.IsNoInsertNull = parent.InsertBuilder.IsNoInsertNull;
|
||||||
|
groupInserable.IsOffIdentity = parent.IsOffIdentity;
|
||||||
|
result +=await groupInserable.AS(item.Key).InsertColumns(names.ToArray()).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
private void CreateTable()
|
private void CreateTable()
|
||||||
{
|
{
|
||||||
var isLog = this.Context.Ado.IsEnableLogEvent;
|
var isLog = this.Context.Ado.IsEnableLogEvent;
|
||||||
|
Loading…
Reference in New Issue
Block a user