Skip to content

Complete output callbacks for queries without result sets - #2277

Open
tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/no-result-output-callbacks
Open

tuncaypeker wants to merge 1 commit into
DapperLib:mainfrom
tuncaypeker:fix/no-result-output-callbacks

Conversation

@tuncaypeker

Copy link
Copy Markdown

Fixes #1244.

When a successful stored procedure returns no result sets, Query, QueryAsync, and QueryUnbufferedAsync exit before calling OnCompleted. Direct DynamicParameters.Get reads can still see output values, but DynamicParameters.Output does not copy them to the target object.

Close the reader and dispatch the completion callback before returning an empty sequence on those paths. This lets the provider finish populating output parameters before callbacks read them. Normal empty result sets with a schema and result sets containing rows retain their existing behavior.

Validation:

  • Reproduced against SQL Server 2025 LocalDB on unmodified upstream main at 1880947 with both Microsoft.Data.SqlClient and System.Data.SqlClient.
  • Thirty regression/control cases cover sync Query and QueryAsync in buffered and unbuffered modes, plus QueryUnbufferedAsync, with no result set, an empty result set, or one row.
  • Before the fix, all ten no-result-set cases fail because the target property stays at -1 instead of 42. Direct output reads return 43 in all cases. The twenty schema-bearing controls pass.
  • After the fix, all thirty new cases pass on net481, net8.0, and net10.0.
  • Selected ProcedureTests, ParameterTests, AsyncTests, QueryMultipleTests, and SQLite tests against SQL Server 2025 LocalDB: net481 413 passed / 11 skipped; net8.0 408 passed / 8 skipped; net10.0 408 passed / 8 skipped. There are no failures. Skips are existing disabled/performance cases and provider-specific unsupported tests.
  • The full repository test suite was not run.
  • Release library build succeeds for net461, netstandard2.0, net8.0, and net10.0 with zero warnings or errors.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't get value of output parameters if the stored procedure doesn't perform any SELECT statement

1 participant