diff --git a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs index 786c347de5..650d99e9d6 100644 --- a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs +++ b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs @@ -364,6 +364,15 @@ internal unsafe ref CAdbcDriver Driver } } + internal unsafe ref CAdbcDriver DriverUnsafe + { + get + { + Debug.Assert(_references > 0); + return ref _nativeDriver; + } + } + internal ImportedAdbcDriver AddReference() { Interlocked.Increment(ref _references); @@ -541,7 +550,7 @@ private unsafe void Dispose(bool disposing) { using (CallHelper caller = new CallHelper()) { - caller.Call(_driver.Driver.DatabaseRelease, ref _nativeDatabase); + caller.Call(_driver.DriverUnsafe.DatabaseRelease, ref _nativeDatabase); } } } @@ -819,7 +828,7 @@ private unsafe void Dispose(bool disposing) { using (CallHelper caller = new CallHelper()) { - caller.Call(_driver.Driver.ConnectionRelease, ref _nativeConnection); + caller.Call(_driver.DriverUnsafe.ConnectionRelease, ref _nativeConnection); } } } @@ -1065,7 +1074,7 @@ private unsafe void Dispose(bool disposing) { using (CallHelper caller = new CallHelper()) { - caller.Call(_driver.Driver.StatementRelease, ref _nativeStatement); + caller.Call(_driver.DriverUnsafe.StatementRelease, ref _nativeStatement); } } }