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 7922850c6226dba6d5e3bd88cbbceab46ad0024e
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Fri Jun 27 14:57:38 2025 +0300

    wip IgniteCommand
---
 .../DataCommon/IgniteCommand.cs                    | 57 +++++++++++++---------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
index f3c0d3d3102..ee52b2cd105 100644
--- 
a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
+++ 
b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteCommand.cs
@@ -29,6 +29,25 @@ public class IgniteCommand : DbCommand
 {
     private IgniteParameterCollection _parameters;
 
+    public override string CommandText { get; set; }
+
+    public override int CommandTimeout { get; set; }
+
+    public override CommandType CommandType { get; set; }
+
+    public override UpdateRowSource UpdatedRowSource { get; set; }
+
+    public override bool DesignTimeVisible { get; set; }
+
+    public CommandSource CommandSource { get; set; }
+
+    protected override DbConnection DbConnection { get; set; }
+
+    protected override DbParameterCollection DbParameterCollection =>
+        _parameters ??= new IgniteParameterCollection();
+
+    protected override DbTransaction DbTransaction { get; set; }
+
     public override void Cancel()
     {
         // No-op.
@@ -48,7 +67,7 @@ public class IgniteCommand : DbCommand
         Console.WriteLine($"IgniteCommand.ExecuteNonQueryAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
         // TODO: Propagate transaction somehow.
-        await using IResultSet<object> resultSet = await 
Sql.ExecuteAsync<object>(
+        await using IResultSet<object> resultSet = await 
GetSql().ExecuteAsync<object>(
             transaction: null,
             statement,
             cancellationToken,
@@ -71,25 +90,6 @@ public class IgniteCommand : DbCommand
         // No-op.
     }
 
-    public override string CommandText { get; set; }
-
-    public override int CommandTimeout { get; set; }
-
-    public override CommandType CommandType { get; set; }
-
-    public override UpdateRowSource UpdatedRowSource { get; set; }
-
-    protected override DbConnection DbConnection { get; set; }
-
-    protected override DbParameterCollection DbParameterCollection =>
-        _parameters ??= new IgniteParameterCollection();
-
-    protected override DbTransaction DbTransaction { get; set; }
-
-    public override bool DesignTimeVisible { get; set; }
-
-    public CommandSource CommandSource { get; set; }
-
     protected override async Task<DbDataReader> 
ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken 
cancellationToken)
     {
         if (CommandSource == CommandSource.SaveChanges)
@@ -107,7 +107,7 @@ public class IgniteCommand : DbCommand
         Console.WriteLine($"IgniteCommand.ExecuteDbDataReaderAsync 
[statement={statement}, parameters={string.Join(", ", args)}]");
 
         // TODO: Propagate transaction somehow.
-        return await Sql.ExecuteReaderAsync(
+        return await GetSql().ExecuteReaderAsync(
             null,
             statement,
             cancellationToken,
@@ -121,11 +121,20 @@ public class IgniteCommand : DbCommand
         throw new NotImplementedException();
     }
 
-    private IIgniteClient IgniteClient => 
((IgniteConnection)DbConnection).Client;
+    private ISql GetSql()
+    {
+        if (DbConnection is not IgniteConnection igniteConn)
+        {
+            throw new InvalidOperationException("DbConnection is not an 
IgniteConnection or is null.");
+        }
 
-    private ISql Sql => IgniteClient.Sql;
+        var client = igniteConn.Client
+                     ?? throw new InvalidOperationException("Ignite client is 
not initialized (connection is not open).");
 
-    private object[] GetArgs() => _parameters?.ToObjectArray() ?? [];
+        return client.Sql;
+    }
 
     private SqlStatement GetStatement() => new(CommandText);
+
+    private object[] GetArgs() => _parameters?.ToObjectArray() ?? [];
 }

Reply via email to