From 15a80bb44d5d5096c76eace040ff1c6fd76512b2 Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 22:33:55 +0800 Subject: [PATCH] fix: pass IParameterCallbacks to GridReader for QueryMultiple Use IParameterCallbacks when constructing GridReader so custom parameter implementations receive OnCompleted callbacks, not only DynamicParameters. Fixes #2179 --- Dapper/SqlMapper.Async.cs | 2 +- Dapper/SqlMapper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dapper/SqlMapper.Async.cs b/Dapper/SqlMapper.Async.cs index eade08cb2..c6377257c 100644 --- a/Dapper/SqlMapper.Async.cs +++ b/Dapper/SqlMapper.Async.cs @@ -1042,7 +1042,7 @@ public static async Task QueryMultipleAsync(this IDbConnection cnn, cmd = command.TrySetupAsyncCommand(cnn, info.ParamReader); reader = await ExecuteReaderWithFlagsFallbackAsync(cmd, wasClosed, CommandBehavior.SequentialAccess, command.CancellationToken).ConfigureAwait(false); - var result = new GridReader(cmd, reader, identity, command.Parameters as DynamicParameters, command.AddToCache, command.CancellationToken); + var result = new GridReader(cmd, reader, identity, command.Parameters as IParameterCallbacks, command.AddToCache, command.CancellationToken); wasClosed = false; // *if* the connection was closed and we got this far, then we now have a reader // with the CloseConnection flag, so the reader will deal with the connection; we // still need something in the "finally" to ensure that broken SQL still results diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index 2fa0e72b7..4c128631a 100644 --- a/Dapper/SqlMapper.cs +++ b/Dapper/SqlMapper.cs @@ -1155,7 +1155,7 @@ private static GridReader QueryMultipleImpl(this IDbConnection cnn, ref CommandD cmd = command.SetupCommand(cnn, info.ParamReader); reader = ExecuteReaderWithFlagsFallback(cmd, wasClosed, CommandBehavior.SequentialAccess); - var result = new GridReader(cmd, reader, identity, command.Parameters as DynamicParameters, command.AddToCache); + var result = new GridReader(cmd, reader, identity, command.Parameters as IParameterCallbacks, command.AddToCache); cmd = null; // now owned by result wasClosed = false; // *if* the connection was closed and we got this far, then we now have a reader // with the CloseConnection flag, so the reader will deal with the connection; we