mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
BulkCopy.OffIdentity
This commit is contained in:
@@ -19,7 +19,9 @@ namespace SqlSugar
|
||||
result.CharacterSet = this.CharacterSet;
|
||||
return result;
|
||||
case DbType.SqlServer:
|
||||
return new SqlServerFastBuilder();
|
||||
var result2= new SqlServerFastBuilder();
|
||||
result2.DbFastestProperties.IsOffIdentity = this.IsOffIdentity;
|
||||
return result2;
|
||||
case DbType.Sqlite:
|
||||
return new SqliteFastBuilder(this.entityInfo);
|
||||
case DbType.Oracle:
|
||||
|
@@ -14,6 +14,7 @@ namespace SqlSugar
|
||||
private string CacheKeyLike { get; set; }
|
||||
private string CharacterSet { get; set; }
|
||||
private bool IsDataAop { get; set; }
|
||||
private bool IsOffIdentity { get; set; }
|
||||
public IFastest<T> SetCharacterSet(string CharacterSet)
|
||||
{
|
||||
this.CharacterSet = CharacterSet;
|
||||
@@ -44,6 +45,11 @@ namespace SqlSugar
|
||||
this.Size = size;
|
||||
return this;
|
||||
}
|
||||
public IFastest<T> OffIdentity()
|
||||
{
|
||||
this.IsOffIdentity = true;
|
||||
return this;
|
||||
}
|
||||
public SplitFastest<T> SplitTable()
|
||||
{
|
||||
SplitFastest<T> result = new SplitFastest<T>();
|
||||
|
@@ -10,5 +10,6 @@ namespace SqlSugar
|
||||
{
|
||||
public bool HasOffsetTime { get; set; }
|
||||
public string[] WhereColumns { get; set; }
|
||||
public bool IsOffIdentity { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ namespace SqlSugar
|
||||
IFastest<T> RemoveDataCache(string cacheKey);
|
||||
IFastest<T> AS(string tableName);
|
||||
IFastest<T> PageSize(int Size);
|
||||
IFastest<T> OffIdentity();
|
||||
IFastest<T> SetCharacterSet(string CharacterSet);
|
||||
IFastest<T> EnableDataAop();
|
||||
int BulkCopy(List<T> datas);
|
||||
|
@@ -38,11 +38,26 @@ namespace SqlSugar
|
||||
SqlBulkCopy copy;
|
||||
if (this.Context.Ado.Transaction == null)
|
||||
{
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection);
|
||||
if (this.DbFastestProperties?.IsOffIdentity == true)
|
||||
{
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.KeepIdentity,null);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.CheckConstraints, (SqlTransaction)this.Context.Ado.Transaction);
|
||||
if (this.DbFastestProperties?.IsOffIdentity == true)
|
||||
{
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.KeepIdentity, (SqlTransaction)this.Context.Ado.Transaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
copy = new SqlBulkCopy((SqlConnection)this.Context.Ado.Connection, SqlBulkCopyOptions.CheckConstraints, (SqlTransaction)this.Context.Ado.Transaction);
|
||||
}
|
||||
}
|
||||
if (this.Context.Ado.Connection.State == ConnectionState.Closed)
|
||||
{
|
||||
|
Reference in New Issue
Block a user