Datarabbit lightweight data access framework (07) -- ispaccesser

Source: Internet
Author: User
(Fully qualified class name: Datarabbit. relation. ispaccesser )

Although irelationaccesser can call some stored procedures without the out parameter, it is best to use the ispaccesser interface to call stored procedures in datarabbit.
Stored Procedures can have both return values and [In, out] parameters. Before encapsulating a stored procedure call, you must first abstract the Parameter Representation of the stored procedure. Use datarabbit Spparameter Parameters of the stored procedure.

Note: The name attribute indicates the parameter name. This parameter name does not need a prefix (such "@"), when calling a stored procedure, datarabbit automatically adds an appropriate parameter prefix to the stored procedure based on the database type.

We can obtain the ispaccesser reference from idataaccesser, the entry point of datarabbit: 

IspaccesserSpaccesser = Dataaccesser. getspaccesser ( Null );


The ispaccesser interface provides two methods to call a stored procedure, which are defined as follows: Public   Interface Ispaccesser: itransactionaccesser
{
///   <Summary>
/// Excutenonequery executes a command-based stored procedure and outputs The out parameter.
///   </Summary>
///   <Param name = "spname"> Stored Procedure name </Param>
///   <Param name = "parms"> All [in] and [In, out] Parameters </Param>
///   <Param name = "outvals"> Name-value Dictionary of the out Parameter </Param>
Void Excutenonequery ( String Spname,Ilist < Spparameter > Parms, Out  Idictionary < String , Object > Outvals );

///   <Summary>
/// Excutenonequery executes a query-type stored procedure and outputs The out parameter.
///   </Summary>
///   <Param name = "spname"> Stored Procedure name </Param>
///   <Param name = "parms"> All [in] and [In, out] Parameters </Param>
///   <Param name = "outvals"> Name-value Dictionary of the out Parameter </Param>
DatasetExcutequery ( String Spname,Ilist < Spparameter > Parms, Out  Idictionary < String , Object > Outvals );
}

CodeHas explained everything, so I will not go into details again.

Suppose that we want to call the stored procedure described in the copy SQL Server database article, we can do this: Ilist < Spparameter > Paralist =   New  List < Spparameter > ();
SpparameterPara1 =   New  Spparameter( " Newdbname " , Parameterdirection. input, " Easnew9 " );
Paralist. Add (para1 );
SpparameterPara2 =   New  Spparameter( " Dbdatadirpath " , Parameterdirection. input, @" C: \ Program Files \ Microsoft SQL Server \ MSSQL \ data \ " );
Paralist. Add (para2 );
SpparameterPara3 =   New  Spparameter( " Souredbname " , Parameterdirection. input, " Autoschedulersystem " );
Paralist. Add (para3 );
SpparameterPara4 =   New  Spparameter( " Sourebackupfilepath " , Parameterdirection. input, @" D: \ sqldatabase \ autoschedulersystem2 " );
Paralist. Add (para4 );
Idictionary < String , Object > Outparas =   Null ;

Spaccesser. Excutenonequery ("Copydb", Paralist,OutOutparas );

Go to: datarabbit lightweight data access framework-Sequence

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.