DapperLib / DapperLib/Dapper

get bool value in code from bit return value

Open
#1,779 2 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

i want to get a bit return value from sp bit return value such this:
CREATE PROC GetBit AS BEGIN DECLARE @JJ BIT = 1; RETURN @JJ END

this code not worked :
`var _params = new DynamicParameters();
_params.Add(
name: "@JJ",
dbType: DbType.Boolean,
direction: ParameterDirection.ReturnValue
);

        IDbConnection dbConnection = new SqlConnection("Data Source=.;Initial Catalog=TestDB;Integrated Security=True");
        if (dbConnection.State != ConnectionState.Open)
            dbConnection.Open();

        await dbConnection.ExecuteAsync("GetBit",
            _params, commandType: CommandType.StoredProcedure);

        var j = _params.Get<bool>("@JJ");
        return j;`

i Don't want use QueryFirstOrDefault. i want to get a return value . because this proc called from other sp and can not use select statement.

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

No repository file or test is identified. Start by reproducing the stored procedure and the ExecuteAsync call with the ReturnValue parameter, then check how the returned value is exposed and converted to bool. Done means retrieving the procedure's bit return value without using SELECT or QueryFirstOrDefault.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend-api-design, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.