DapperLib / DapperLib/Dapper

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

Open
#1,244 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

In my stored procedure, if some input parameters do not meet some conditions, it will set error codes to an output parameter instead of performing a SELECT to return a result set. And when it happens, I can't get value of the output parameter from the DynamicParameters.

In the source code of SqlMapper.cs, I found this at line 1090

if (reader.FieldCount == 0) //https://code.google.com/p/dapper-dot-net/issues/detail?id=57
     yield break;

Because the FieldCount is 0 in this case, command.OnCompleted() is never called, so that outputs are not set back to DynamicParameters.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Dapper/SqlMapper.cs around line 1090 and trace how a stored procedure with FieldCount equal to 0 completes execution. Follow the DynamicParameters output-parameter path and existing command completion behavior. Done means output parameters are available even when the procedure returns no result set, with the relevant behavior covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.