Knight Data Access Layer
Loading By Stored Procedure
Basic Tasks C# > Loading Data > Loading By Stored Procedure

Results from Stored Procedures can be automatically mapped to objects.  An example is below.

 

//Get the current instance of the helper

IDataHelper db = DataHelper.SessionFactory();

 

//Setup the parameters

string storedProcedure = "GetAll_Customers";

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

parms.Add("@CustomerType", 1);

 

List<Customer> list = db.LoadFromSproc<Customer>(storedProcedure, parms);