Knight Data Access Layer
Execute Stored Procedures
Basic Tasks C# > Database Commands > Execute Stored Procedures

Any stored procedure can be executed.  It is possible to execute scalar and non query stored procedures with output parameters.  See ExecuteScalarSproc and ExecuteNonQuerySproc for more information.  To load records from a stored procedure, see Loading By Stored Procedure.

 

//Get the current instance of the helper

IDataHelper db = DataHelper.SessionFactory();

 

//Parameters

Dictionary<string, object> parms = new Dictionary<string, object>();

parms.Add("ExpirationType", "Credit Card");

string storedProcedure = "CalculateAverageTransactionSale";

 

decimal results = Convert.ToDecimal(db.ExecuteScalarSproc(storedProcedure));