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