This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-22133-bak
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit 31971563436119aa7ed80dbe562c2829ea61260a
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Fri Jun 27 15:53:34 2025 +0300

    Propagate transaction
---
 .../DataCommon/IgniteCommand.cs                    | 15 ++++++----
 .../DataCommon/IgniteTransaction.cs                | 32 +++++++++-------------
 2 files changed, 22 insertions(+), 25 deletions(-)

diff --git 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
index 3726f0a1873..937393cb67b 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
@@ -25,6 +25,7 @@ using System.Threading.Tasks;
 using Microsoft.EntityFrameworkCore.Diagnostics;
 using Sql;
 using Table;
+using Transactions;
 
 public class IgniteCommand : DbCommand
 {
@@ -67,9 +68,8 @@ public class IgniteCommand : DbCommand
         // TODO: Remove debug output.
         Console.WriteLine($"IgniteCommand.ExecuteNonQueryAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
-        // TODO: Propagate transaction somehow.
         await using IResultSet<object> resultSet = await 
GetSql().ExecuteAsync<object>(
-            transaction: null,
+            transaction: GetTransaction(),
             statement,
             cancellationToken,
             args);
@@ -92,9 +92,8 @@ public class IgniteCommand : DbCommand
         // TODO: Remove debug output.
         Console.WriteLine($"IgniteCommand.ExecuteScalarAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
-        // TODO: Propagate transaction somehow.
         await using IResultSet<IIgniteTuple> resultSet = await 
GetSql().ExecuteAsync(
-            transaction: null,
+            transaction: GetTransaction(),
             statement,
             cancellationToken,
             args);
@@ -131,9 +130,8 @@ public class IgniteCommand : DbCommand
         // TODO: Remove debug output.
         Console.WriteLine($"IgniteCommand.ExecuteDbDataReaderAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
-        // TODO: Propagate transaction somehow.
         return await GetSql().ExecuteReaderAsync(
-            null,
+            GetTransaction(),
             statement,
             cancellationToken,
             args);
@@ -161,5 +159,10 @@ public class IgniteCommand : DbCommand
 
     private SqlStatement GetStatement() => new(CommandText);
 
+    private ITransaction? GetTransaction() =>
+        DbTransaction is IgniteTransaction igniteTx
+            ? igniteTx.InternalTransaction
+            : null;
+
     private object[] GetArgs() => _parameters?.ToObjectArray() ?? [];
 }
diff --git 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs
 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs
index 4df58c79ce8..56a4b73bc05 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs
@@ -15,41 +15,35 @@
 
 namespace Apache.Ignite.EntityFrameworkCore.DataCommon;
 
-using System;
 using System.Data;
 using System.Data.Common;
 using System.Threading;
 using System.Threading.Tasks;
-using Apache.Ignite.Transactions;
+using Transactions;
 
 public class IgniteTransaction : DbTransaction
 {
-    private readonly ITransaction _tx;
-
     public IgniteTransaction(ITransaction tx, IsolationLevel isolationLevel, 
DbConnection connection)
     {
-        _tx = tx;
+        InternalTransaction = tx;
         IsolationLevel = isolationLevel;
         DbConnection = connection;
     }
 
-    public override void Commit()
-    {
-        throw new NotImplementedException();
-    }
+    public override IsolationLevel IsolationLevel { get; }
 
-    public override void Rollback()
-    {
-        throw new NotImplementedException();
-    }
+    internal ITransaction InternalTransaction { get; }
 
-    public override async Task CommitAsync(CancellationToken 
cancellationToken) =>
-        await _tx.CommitAsync();
+    protected override DbConnection DbConnection { get; }
 
-    public override async Task RollbackAsync(string savepointName, 
CancellationToken cancellationToken) =>
-        await _tx.RollbackAsync();
+    public override void Commit() => 
CommitAsync(CancellationToken.None).GetAwaiter().GetResult();
 
-    protected override DbConnection DbConnection { get; }
+    public override void Rollback() => RollbackAsync(null!, 
CancellationToken.None).GetAwaiter().GetResult();
+
+    public override async Task CommitAsync(CancellationToken cancellationToken 
= default) =>
+        await InternalTransaction.CommitAsync();
+
+    public override async Task RollbackAsync(string savepointName, 
CancellationToken cancellationToken = default) =>
+        await InternalTransaction.RollbackAsync();
 
-    public override IsolationLevel IsolationLevel { get; }
 }

Reply via email to