Skip to content

Commit

Permalink
Fix SqlServer's InsertBatch with transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
firebie committed May 29, 2014
1 parent f933080 commit 7dbd5b8
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Source/Data/DataProvider/SqlDataProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,10 @@ public override DateTimeOffset GetDateTimeOffset(int i)
int maxBatchSize,
DbManager.ParameterProvider<T> getParameters)
{
if (db.Transaction != null)
return base.InsertBatch(db, insertText, collection, members, maxBatchSize, getParameters);

var idx = insertText.IndexOf('\n');
var tbl = insertText.Substring(0, idx).Substring("INSERT INTO ".Length).TrimEnd('\r');
var rd = new BulkCopyReader(members, collection);
var bc = new SqlBulkCopy((SqlConnection)db.Connection, SqlDataProvider.SqlBulkCopyOptions, null)
var bc = new SqlBulkCopy((SqlConnection)db.Connection, SqlDataProvider.SqlBulkCopyOptions, (SqlTransaction)db.Transaction)
{
BatchSize = maxBatchSize,
DestinationTableName = tbl,
Expand Down

0 comments on commit 7dbd5b8

Please sign in to comment.