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 891651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:55:25+00:00 2026-05-15T13:55:25+00:00

Looking for suggestions on cleanest way to get the return value and the result

  • 0

Looking for suggestions on cleanest way to get the return value and the result set (without passing a referenced parameter to the stored proc).

MY stored procs have return values to show errors, etc and they end with a select statement to get the information. With regular commands I would create an output parameter which would hold the return value. I can’t change the stored procs in the db so I can’t pass a different output parameter other then the return value.

thoughts??

  • 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-05-15T13:55:25+00:00Added an answer on May 15, 2026 at 1:55 pm

    When you create a stored procedure in the LINQ to SQL Data Context designer by dragging it from the Server Explorer, the designer will analyze the sproc to determine if it returns a result set. Unless it features heavy dynamic SQL, it’s usually spot on.

    If it does, the method generated returns ISingleResult<T> where T is either a class generated from an analysis of your sproc to fit the shape of the result set, or one you specify in the sproc properties page. Because ISingleResult derives from IEnumerable, most people do a simple foreach on the result to get their result set. But what most people forget is that ISingleResult also derives from IFunctionResult, which has a property called ReturnValue. This is the return value from the sproc.

    So all you have to do is something along the lines of:

    using(var dc = new MyDataContext())
    {
        var results = dc.MyStoredProcedure();
        var returnValue = (int)results.ReturnValue; // note that ReturnValue is of type object and must be cast.
        foreach(var row in results)
        {
            // process row
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for suggestions for an efficient way to maintain basic audit fields for entities
I'm just looking for suggestions on the best way to do this... I need
Looking for suggestions as to the best way to do this (I know there
I'm looking for suggestions how to set a div to min-height:100% when it has
I'm looking for suggestions, or really good tutorials on how to handle passing ids
I'm looking for suggestions on the easiest way to create charts and have them
I am looking for suggestions as to the best way to design objects for
I am looking for suggestions on the best way to sync mySQL tables (myISAM)
I'm looking for suggestions as to the best way to parse the following calendar...
Looking for suggestions on file system management tools. We have several terabytes of images,

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.