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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:41:30+00:00 2026-06-08T05:41:30+00:00

Is there any examples to be found for running a stored procedure on serviceStack

  • 0

Is there any examples to be found for running a stored procedure on serviceStack MVC using ormlite? mythz ? seen this block of code:

var results = new List<EnergyCompare>
                    {dbFactory.Exec(dbCmd =>
                       {
                          dbCmd.CommandType = CommandType.StoredProcedure;
                          dbCmd.Parameters.Add(new SqlParameter("@id", 1));
                          dbCmd.CommandText = "GetAuthorById";
                          return dbCmd.ExecuteReader().ConvertTo<EnergyCompare>();
                       }
                    )};

but came with the text of never worked on the google groups!

i can also write this:

using(var db = new SwitchWizardDb())
            {
             var results2 = db.dbCmd.ExecuteProcedure()   
            }

but not sure how to complete this with parameters, and in the source code I looked at, it said obsolete?

thanks

  • 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-08T05:41:31+00:00Added an answer on June 8, 2026 at 5:41 am

    Well I figured it was best to roll my own handler so have created this, any thoughts would be most welcome, especially with how I could pass over params in some kind of func or something:

    I have a main class to deal with easy access to my connection object:

    public class DatabaseNameSp : IDisposable
    {
        private readonly SqlConnection _spConn = new SqlConnection(DatabaseNameSp .dbConString);
        public readonly SqlCommand SpCmd;
    
        public DatabaseNameSp (string procedureName)
        {
           _spConn.Open();
    
            SpCmd = new SqlCommand
                        {
                            Connection = _spConn,
                            CommandType = CommandType.StoredProcedure,
                            CommandText = procedureName
                        };
        }
    
        public void Dispose()
        {
             _spConn.Close();
             SpCmd.Dispose();
        }
    }
    

    usage:

    using (var db = new DatabaseNameSp ("procedurenname"))
                {
                    db.SpCmd.Parameters.Add(new SqlParameter("@Id", 1));
    
                    var rdr = db.SpCmd.ExecuteReader(CommandBehavior.CloseConnection);
    
                    var results = new List<CustomDTO>();
                    while (rdr.Read())
                    {
                        results.Add(new CustomDTO { Name = rdr["name"].ToString(), Id = rdr["id"].ToString() });
                    }
                    return new CustomDTOResponse { Results = results };
                }
    

    Any thoughts !

    thanks

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

Sidebar

Related Questions

Are there any good examples of mvc routing wherein every 404 page not found
Are there any examples of Store Locators using Google API v3 without using a
Are there any examples of successful commercial apps written with PhoneGap? If I were
Does the asp.net ReportViewer control work with LinqDataSource? If so are there any examples
Are there any tutorials or examples on how to play WAV files on Mac
Is there any difference between the following two examples and should one be preferred
Is there any website where people share and discuss good examples of object-oriented design?
Are there any recommended libraries, patterns or examples on how to implement Prefetching and/or
Are there any libraries or utilities that will formally spell out the time? Examples:
Is there any way to compute length of va_list ? All examples I saw

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.