Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:17:12+00:00 2026-06-13T06:17:12+00:00

We are using Dapper.Net extensively and are very happy with it. However we have

  • 0

We are using Dapper.Net extensively and are very happy with it. However we have come across an issue when trying to retrieve output parameters from stored procedures using multi.Read:

var p = new DynamicParameters(); 
p.Add("@id", id); 
p.Add("TotalRows", dbType: DbType.Int32, direction: ParameterDirection.Output); 

using (var multi = cnn.QueryMultiple(string.Format("dbo.[{0}]", spName), p,
    commandType: CommandType.StoredProcedure))
{  
    int TotalRows = p.Get<int>("@TotalRows"); //This is always null

    var results = multi.Read<New_Supplier>().ToList<IDBSupplier>();
    var areas = multi.Read<node>().ToList<IDBNode>();
    var categories = multi.Read<node>().ToList<IDBNode>();
    int TotalRows = multi.Read<int>().FirstOrDefault(); // This works

}

However, if we use the connection.Query syntax to get a single resultset the output parameter is populated:

var result = cnn.Query<New_Supplier>(string.Format("spname"), p,
    commandType: CommandType.StoredProcedure).ToList<New_Supplier>();
int TotalRows = p.Get<int>("@TotalRows");

The error is that the sqlValue of AttachedParam on the output parameter in the Dapper DynamicParameters is always null.

To work around this we have added the value of the output parameter to the result sets of the stored procedure and are reading it that way.

Why is the parameter always null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:17:13+00:00Added an answer on June 13, 2026 at 6:17 am

    In a TDS stream, the OUT parameters are at the end. In your Query<T> example, you have consumed the TDS stream:

    var result = cnn.Query<New_Supplier>(string.Format("spname"), p,
        commandType: CommandType.StoredProcedure).ToList<New_Supplier>();
    int TotalRows = p.Get<int>("@TotalRows");
    

    so because you have consumed the stream, the new parameter values have been reached, and you should have the values available. In the QueryMultiple example, you have not reached the end of the TDS stream. Try moving the p.Get:

    var p = new DynamicParameters(); 
    p.Add("@id", id); 
    p.Add("TotalRows", dbType: DbType.Int32, direction: ParameterDirection.Output); 
    
    using (var multi = cnn.QueryMultiple(string.Format("dbo.[{0}]", spName), p,
        commandType: CommandType.StoredProcedure))
    {      
        var results = multi.Read<New_Supplier>().ToList<IDBSupplier>();
        var areas = multi.Read<node>().ToList<IDBNode>();
        var categories = multi.Read<node>().ToList<IDBNode>();
    }
    int TotalRows = p.Get<int>("@TotalRows");
    

    If that doesn’t work, let me know ;p

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that I'm trying to execute using Dapper that is
I have a very similar question to Dapper-dot-net "no column name" , but the
I'm trying to perform a very standard multi mapping query using Dapper, and I'm
I am trying to test out some Dapper stuff using LinqPad. Dapper needs a
I'm using dapper for a mvc3 project at work, and I like it. However,
(This code is using Dapper Dot Net in C#) This code works: var command
Folks, Im considering using a microORM such as Dapper.net for the read access component
When using Dapper-dot-net, if your querying to a strongly typed results, and your SQL
I am working on an ASP.NET MVC application using SQL Dapper for retrieval and
I got a problem using dapper to attach parameters to my MySql queries. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.