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 25a69aa067df03bd80d50edea1b1bcf12a99db81
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Fri Jun 27 14:51:44 2025 +0300

    wip IgniteCommand
---
 .../DataCommon/IgniteCommand.cs                    | 66 ++++++++++++----------
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
index 237d7dc7e60..f3c0d3d3102 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
@@ -16,20 +16,18 @@
 namespace Apache.Ignite.EntityFrameworkCore.DataCommon;
 
 #nullable disable // TODO: Remove nullable disable.
-
 using System;
 using System.Data;
 using System.Data.Common;
 using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
 using System.Threading;
 using System.Threading.Tasks;
-using Apache.Ignite.Sql;
 using Microsoft.EntityFrameworkCore.Diagnostics;
+using Sql;
 
 public class IgniteCommand : DbCommand
 {
-    private IgniteParameterCollection _parameters = null;
+    private IgniteParameterCollection _parameters;
 
     public override void Cancel()
     {
@@ -41,39 +39,19 @@ public class IgniteCommand : DbCommand
         return 
ExecuteNonQueryAsync(CancellationToken.None).GetAwaiter().GetResult();
     }
 
-    protected override async Task<DbDataReader> 
ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken 
cancellationToken)
-    {
-        if (CommandSource == CommandSource.SaveChanges)
-        {
-            // Ignite-specific: SaveChangesDataReader is used to return the 
number of rows affected.
-            var rowsAffected = await ExecuteNonQueryAsync(cancellationToken);
-
-            return new IgniteSaveChangesDataReader(rowsAffected);
-        }
-
-        var args = _parameters?.ToObjectArray() ?? Array.Empty<object>();
-
-        // TODO: Remove debug output.
-        Console.WriteLine($"IgniteCommand.ExecuteDbDataReaderAsync 
[statement={CommandText}, parameters={string.Join(", ", args)}]");
-
-        // TODO: Propagate transaction somehow.
-        return await Sql.ExecuteReaderAsync(
-            null,
-            CommandText,
-            args);
-    }
-
     public override async Task<int> ExecuteNonQueryAsync(CancellationToken 
cancellationToken)
     {
-        var args = _parameters?.ToObjectArray() ?? Array.Empty<object>();
+        var args = GetArgs();
+        var statement = GetStatement();
 
         // TODO: Remove debug output.
-        Console.WriteLine($"IgniteCommand.ExecuteNonQueryAsync 
[statement={CommandText}, parameters={string.Join(", ", args)}]");
+        Console.WriteLine($"IgniteCommand.ExecuteNonQueryAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
         // TODO: Propagate transaction somehow.
         await using IResultSet<object> resultSet = await 
Sql.ExecuteAsync<object>(
             transaction: null,
-            CommandText,
+            statement,
+            cancellationToken,
             args);
 
         Debug.Assert(!resultSet.HasRowSet, "!resultSet.HasRowSet");
@@ -90,7 +68,7 @@ public class IgniteCommand : DbCommand
 
     public override void Prepare()
     {
-        throw new NotImplementedException();
+        // No-op.
     }
 
     public override string CommandText { get; set; }
@@ -112,6 +90,30 @@ public class IgniteCommand : DbCommand
 
     public CommandSource CommandSource { get; set; }
 
+    protected override async Task<DbDataReader> 
ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken 
cancellationToken)
+    {
+        if (CommandSource == CommandSource.SaveChanges)
+        {
+            // Ignite-specific: SaveChangesDataReader is used to return the 
number of rows affected.
+            var rowsAffected = await ExecuteNonQueryAsync(cancellationToken);
+
+            return new IgniteSaveChangesDataReader(rowsAffected);
+        }
+
+        var args = GetArgs();
+        var statement = GetStatement();
+
+        // TODO: Remove debug output.
+        Console.WriteLine($"IgniteCommand.ExecuteDbDataReaderAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
+
+        // TODO: Propagate transaction somehow.
+        return await Sql.ExecuteReaderAsync(
+            null,
+            statement,
+            cancellationToken,
+            args);
+    }
+
     protected override DbParameter CreateDbParameter() => new 
IgniteParameter();
 
     protected override DbDataReader ExecuteDbDataReader(CommandBehavior 
behavior)
@@ -122,4 +124,8 @@ public class IgniteCommand : DbCommand
     private IIgniteClient IgniteClient => 
((IgniteConnection)DbConnection).Client;
 
     private ISql Sql => IgniteClient.Sql;
+
+    private object[] GetArgs() => _parameters?.ToObjectArray() ?? [];
+
+    private SqlStatement GetStatement() => new(CommandText);
 }

Reply via email to