mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Update 达梦 BulkCopy Identity
This commit is contained in:
parent
a051641dca
commit
4f09dc51be
@ -33,7 +33,9 @@ namespace SqlSugar
|
||||
resultConnector.CharacterSet = this.CharacterSet;
|
||||
return resultConnector;
|
||||
case DbType.Dm:
|
||||
return new DmFastBuilder();
|
||||
var result3= new DmFastBuilder();
|
||||
result3.DbFastestProperties.IsOffIdentity = this.IsOffIdentity;
|
||||
return result3;
|
||||
case DbType.ClickHouse:
|
||||
var resultConnectorClickHouse = InstanceFactory.CreateInstance<IFastBuilder>("SqlSugar.ClickHouse.ClickHouseFastBuilder");
|
||||
resultConnectorClickHouse.CharacterSet = this.CharacterSet;
|
||||
|
@ -17,7 +17,34 @@ namespace SqlSugar
|
||||
};
|
||||
public async Task<int> ExecuteBulkCopyAsync(DataTable dt)
|
||||
{
|
||||
return await _Execute(dt);
|
||||
if (DbFastestProperties?.IsOffIdentity == true)
|
||||
{
|
||||
var isNoTran = this.Context.Ado.IsNoTran()&&this.Context.CurrentConnectionConfig.IsAutoCloseConnection;
|
||||
try
|
||||
{
|
||||
if(isNoTran)
|
||||
this.Context.Ado.BeginTran();
|
||||
|
||||
this.Context.Ado.ExecuteCommand($"SET IDENTITY_INSERT {dt.TableName} ON");
|
||||
var result=await _Execute(dt);
|
||||
this.Context.Ado.ExecuteCommand($"SET IDENTITY_INSERT {dt.TableName} OFF");
|
||||
|
||||
if (isNoTran)
|
||||
this.Context.Ado.CommitTran();
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (isNoTran)
|
||||
this.Context.Ado.CommitTran();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _Execute(dt);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<int> _Execute(DataTable dt)
|
||||
|
Loading…
Reference in New Issue
Block a user