Skip to content

Commit 656459a

Browse files
Fix commit.
1 parent 7485d81 commit 656459a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/PhenX.EntityFrameworkCore.BulkInsert/BulkInsertProviderBase.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public virtual async Task<List<T>> BulkInsertReturnEntities<T>(
155155

156156
result = await CopyFromTempTableAsync<T>(sync, context, tableInfo, tableName, true, options, onConflict, cancellationToken: ctk);
157157

158+
// Commit the transaction if we own them.
158159
await Commit(sync, connectionInfo, ctk);
159160
}
160161
finally
@@ -232,6 +233,8 @@ public virtual async Task BulkInsert<T>(
232233
var (tableName, _) = await PerformBulkInsertAsync(sync, context, tableInfo, entities, options, tempTableRequired: true, ctk: ctk);
233234

234235
await CopyFromTempTableAsync<T>(sync, context, tableInfo, tableName, false, options, onConflict, ctk);
236+
237+
// Commit the transaction if we own them.
235238
await Commit(sync, connectionInfo, ctk);
236239
}
237240
finally
@@ -267,9 +270,17 @@ public virtual async Task BulkInsert<T>(
267270

268271
var properties = tableInfo.GetProperties(options.CopyGeneratedColumns);
269272

270-
await BulkInsert(false, context, tableInfo, entities, tableName, properties, options, ctk);
273+
try
274+
{
275+
await BulkInsert(false, context, tableInfo, entities, tableName, properties, options, ctk);
271276

272-
await Finish(sync, connectionInfo, ctk);
277+
// Commit the transaction if we own them.
278+
await Commit(sync, connectionInfo, ctk);
279+
}
280+
finally
281+
{
282+
await Finish(sync, connectionInfo, ctk);
283+
}
273284

274285
return (tableName, connectionInfo.Connection);
275286
}

0 commit comments

Comments
 (0)