Skip to content

Commit e0b74e5

Browse files
Ticket #8 : Fix transaction
1 parent 4277709 commit e0b74e5

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

src/EFCore.Cassandra/Update/Internal/CassandraBatchExecutor.cs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) SimpleIdServer. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
using Cassandra.Data;
34
using Microsoft.EntityFrameworkCore.Infrastructure;
45
using Microsoft.EntityFrameworkCore.Storage;
56
using Microsoft.EntityFrameworkCore.Update;
@@ -87,39 +88,18 @@ private async Task<int> ExecuteAsync(
8788
var commandBatches = parameters.Item1;
8889
var connection = parameters.Item2;
8990
var rowsAffected = 0;
90-
IDbContextTransaction startedTransaction = null;
9191
try
9292
{
93-
if (connection.CurrentTransaction == null
94-
&& (connection as ITransactionEnlistmentManager)?.EnlistedTransaction == null
95-
&& Transaction.Current == null
96-
&& CurrentContext.Context.Database.AutoTransactionsEnabled)
97-
{
98-
startedTransaction = await connection.BeginTransactionAsync(cancellationToken);
99-
}
100-
else
101-
{
102-
await connection.OpenAsync(cancellationToken);
103-
}
104-
93+
await connection.OpenAsync(cancellationToken);
10594
foreach (var batch in commandBatches)
10695
{
10796
await batch.ExecuteAsync(connection, cancellationToken);
10897
rowsAffected += batch.ModificationCommands.Count;
10998
}
110-
111-
startedTransaction?.Commit();
11299
}
113100
finally
114101
{
115-
if (startedTransaction != null)
116-
{
117-
startedTransaction.Dispose();
118-
}
119-
else
120-
{
121-
connection.Close();
122-
}
102+
connection.Close();
123103
}
124104

125105
return rowsAffected;

0 commit comments

Comments
 (0)