Servicestack.ormlite Calling stored Procedures

Source: Internet
Author: User

There was a problem when I called the stored procedure recently about Servicestack.ormlite. Discover that Servicestack.ormlite cannot invoke stored procedures, or that it does not implement the requirements I want. When making paged queries, I need to pass in parameter outgoing parameters.

Servicestack.ormlite Call stored Procedure Code:

Stored procedure: usp_getcarcomponentslist

Incoming parameters: @page, @limit

Outgoing parameters: @pageCount, @totalCount

Problem Description: Parameters passed in the database can not be received, do not know whether it is a writing problem, or other reasons. How do I receive the output parameters, even if they are used?

 var  list = db. Sqllist<common_carcomponents_params> ( " exec usp_getcarcomponentslist @page, @limit, @pageCount, @totalCount    Span style= "color: #800000;"                        > ", new   = Trademarkid, subtrademarkid  = Subtrademarkid, page  = page, limit 
     = limit, PageCount  = 0 = 0                      });

Solution: Use Dapper's dynamicparameters for implementation.

1. Steps:

Pm> Install-package Dapper
"Dapper 1.42" is already installed.
Adding "Dapper 1.42" to Product.serviceinterface.
"Dapper 1.42" was successfully added to Product.serviceinterface.

Code:

 varDynamicparameters =Newdynamicparameters (); Dynamicparameters.add ("@TrademarkId", Trademarkid); Dynamicparameters.add ("@SubTrademarkId", Subtrademarkid); Dynamicparameters.add ("@page", page); Dynamicparameters.add ("@limit", limit); Dynamicparameters.add ("@pageCount", DbType:DbType.Int32, direction:ParameterDirection.Output); Dynamicparameters.add ("@totalCount", DbType:DbType.Int32, direction:ParameterDirection.Output); varList2 = db. Querymultiple ("usp_getcarcomponentslist", Dynamicparameters, commandType:CommandType.StoredProcedure); varFirstset =List2. Read ().                    ToList (); intPageCount = dynamicparameters.get<int> ("@pageCount"); intTotalCount = dynamicparameters.get<int> ("@totalCount");

It's obvious that this is a paged query, and then it goes without saying.

Servicestack.ormlite Calling stored Procedures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.