diff --git a/csharp/src/Client/AdbcCommand.cs b/csharp/src/Client/AdbcCommand.cs
index 7ad0678aff..d87f427c76 100644
--- a/csharp/src/Client/AdbcCommand.cs
+++ b/csharp/src/Client/AdbcCommand.cs
@@ -129,16 +129,12 @@ public override CommandType CommandType
///
/// Gets or sets the name of the command timeout property for the underlying ADBC driver.
+ /// When set, will propagate the value to the driver via this property.
+ /// When not set, only stores the value locally.
///
- public string AdbcCommandTimeoutProperty
+ public string? AdbcCommandTimeoutProperty
{
- get
- {
- if (string.IsNullOrEmpty(_commandTimeoutProperty))
- throw new InvalidOperationException("CommandTimeoutProperty is not set.");
-
- return _commandTimeoutProperty!;
- }
+ get => _commandTimeoutProperty;
set => _commandTimeoutProperty = value;
}
@@ -147,9 +143,11 @@ public override int CommandTimeout
get => _timeout;
set
{
- // ensures the property exists before setting the CommandTimeout value
- string property = AdbcCommandTimeoutProperty;
- _adbcStatement.SetOption(property, value.ToString(CultureInfo.InvariantCulture));
+ // if the driver property is set, propagate the timeout value to the driver
+ if (!string.IsNullOrEmpty(_commandTimeoutProperty))
+ {
+ _adbcStatement.SetOption(_commandTimeoutProperty!, value.ToString(CultureInfo.InvariantCulture));
+ }
_timeout = value;
}
}
diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/Client/ClientTests.cs b/csharp/test/Apache.Arrow.Adbc.Tests/Client/ClientTests.cs
index e1d5a91781..b8afa26260 100644
--- a/csharp/test/Apache.Arrow.Adbc.Tests/Client/ClientTests.cs
+++ b/csharp/test/Apache.Arrow.Adbc.Tests/Client/ClientTests.cs
@@ -221,12 +221,12 @@ internal void TestConnectionStringParsing(ConnectionStringExample connectionStri
if (!string.IsNullOrEmpty(connectionStringExample.CommandTimeoutProperty))
{
- Assert.True(cmd.AdbcCommandTimeoutProperty == connectionStringExample.CommandTimeoutProperty);
- Assert.True(cmd.CommandTimeout == connectionStringExample.CommandTimeout);
+ Assert.Equal(connectionStringExample.CommandTimeoutProperty, cmd.AdbcCommandTimeoutProperty);
+ Assert.Equal(connectionStringExample.CommandTimeout, cmd.CommandTimeout);
}
else
{
- Assert.Throws(() => cmd.AdbcCommandTimeoutProperty);
+ Assert.Null(cmd.AdbcCommandTimeoutProperty);
}
}
}