mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Update Insertable.PageSize
This commit is contained in:
parent
0386d4fe4b
commit
2d253bcf78
@ -24,10 +24,30 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (PageSize == 0) { PageSize = 1000; }
|
if (PageSize == 0) { PageSize = 1000; }
|
||||||
var result = 0;
|
var result = 0;
|
||||||
this.Context.Utilities.PageEach(DataList, PageSize, pageItem =>
|
var isNoTran = this.Context.Ado.IsNoTran();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
result += this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent,DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteCommand();
|
if (isNoTran)
|
||||||
});
|
{
|
||||||
|
this.Context.Ado.BeginTran();
|
||||||
|
}
|
||||||
|
this.Context.Utilities.PageEach(DataList, PageSize, pageItem =>
|
||||||
|
{
|
||||||
|
result += this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteCommand();
|
||||||
|
});
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
this.Context.Ado.CommitTran();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
this.Context.Ado.RollbackTran();
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public async Task<int> ExecuteCommandAsync()
|
public async Task<int> ExecuteCommandAsync()
|
||||||
@ -38,10 +58,30 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (PageSize == 0) { PageSize = 1000; }
|
if (PageSize == 0) { PageSize = 1000; }
|
||||||
var result = 0;
|
var result = 0;
|
||||||
await this.Context.Utilities.PageEachAsync(DataList, PageSize,async pageItem =>
|
var isNoTran = this.Context.Ado.IsNoTran();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
result += await this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteCommandAsync();
|
if (isNoTran)
|
||||||
});
|
{
|
||||||
|
await this.Context.Ado.BeginTranAsync();
|
||||||
|
}
|
||||||
|
await this.Context.Utilities.PageEachAsync(DataList, PageSize, async pageItem =>
|
||||||
|
{
|
||||||
|
result +=await this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
await this.Context.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
await this.Context.Ado.RollbackTranAsync();
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +89,34 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (DataList.Count() == 1 && DataList.First() == null)
|
if (DataList.Count() == 1 && DataList.First() == null)
|
||||||
{
|
{
|
||||||
return new List<long>();
|
return new List<long>();
|
||||||
}
|
}
|
||||||
if (PageSize == 0) { PageSize = 1000; }
|
if (PageSize == 0) { PageSize = 1000; }
|
||||||
var result = new List<long>();
|
var result = new List<long>();
|
||||||
this.Context.Utilities.PageEach(DataList, PageSize, pageItem =>
|
var isNoTran = this.Context.Ado.IsNoTran();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
result.AddRange( this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteReturnSnowflakeIdList());
|
if (isNoTran)
|
||||||
});
|
{
|
||||||
|
this.Context.Ado.BeginTran();
|
||||||
|
}
|
||||||
|
this.Context.Utilities.PageEach(DataList, PageSize, pageItem =>
|
||||||
|
{
|
||||||
|
result.AddRange(this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteReturnSnowflakeIdList());
|
||||||
|
});
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
this.Context.Ado.CommitTran();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
this.Context.Ado.RollbackTran();
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public async Task<List<long>> ExecuteReturnSnowflakeIdListAsync()
|
public async Task<List<long>> ExecuteReturnSnowflakeIdListAsync()
|
||||||
@ -67,10 +127,30 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (PageSize == 0) { PageSize = 1000; }
|
if (PageSize == 0) { PageSize = 1000; }
|
||||||
var result = new List<long>();
|
var result = new List<long>();
|
||||||
await this.Context.Utilities.PageEachAsync(DataList, PageSize,async pageItem =>
|
var isNoTran = this.Context.Ado.IsNoTran();
|
||||||
|
try
|
||||||
{
|
{
|
||||||
result.AddRange(await this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteReturnSnowflakeIdListAsync());
|
if (isNoTran)
|
||||||
});
|
{
|
||||||
|
await this.Context.Ado.BeginTranAsync();
|
||||||
|
}
|
||||||
|
await this.Context.Utilities.PageEachAsync(DataList, PageSize, async pageItem =>
|
||||||
|
{
|
||||||
|
result.AddRange(await this.Context.Insertable(pageItem).AS(TableName).EnableDiffLogEventIF(IsEnableDiffLogEvent, DiffModel).InsertColumns(InsertColumns.ToArray()).ExecuteReturnSnowflakeIdListAsync());
|
||||||
|
});
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
await this.Context.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (isNoTran)
|
||||||
|
{
|
||||||
|
await this.Context.Ado.RollbackTranAsync();
|
||||||
|
}
|
||||||
|
throw;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user