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