(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