Knight Data Access Layer
LoadFromSproc<T>(String) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > DataHelper Class > LoadFromSproc Method : LoadFromSproc<T>(String) Method
Generic class type
The stored procedure name
Load records from a stored procedure and automatically map it to a class
Syntax
Public Overloads Function LoadFromSproc(Of T As {Class, New})( _
   ByVal storedProcedureName As String _
) As List(Of T)
Dim instance As DataHelper
Dim storedProcedureName As String
Dim value As List(Of T)
 
value = instance.LoadFromSproc(Of T)(storedProcedureName)
public List<T> LoadFromSproc<T>( 
   string storedProcedureName
)
where T: class, new()
public: List<T*>* LoadFromSproc<T>( 
   string* storedProcedureName
) 
where T: ref class, gcnew()
public:
List<T^>^ LoadFromSprocgeneric<typename T>
( 
   String^ storedProcedureName
) 
where T: ref class, gcnew()

Parameters

storedProcedureName
The stored procedure name

Type Parameters

T
Generic class type

Return Value

A list of objects
Example
//Get the current thread static safe instance of the helper
IDataHelper db = DataHelper.SessionFactory();
 
//Specify User Name and License Key from the receipt, leave blank for trial mode
//db.UserName = "John Smith 1234";
//db.LicenseKey = "asdfl219==";
 
//Open the database connection
db.OpenConnection();
 
string storedProcedure = "GetTopTenCustomers";
 
List<Customer> list = db.LoadFromSproc<Customer>(storedProcedure);
 
db.CloseConnection();
'Get the current thread static safe instance of the helper
Dim db As IDataHelper = DataHelper.SessionFactory()
 
'Specify User Name and License Key from the receipt, leave blank for trial mode
'db.UserName = "John Smith 1234"
'db.LicenseKey = "asdfl219=="
 
'Open the database connection
db.OpenConnection()
 
Dim storedProcedure As String = "GetTopTenCustomers"
 
Dim list As List(Of Customer) = db.LoadFromSproc(Of Customer)(storedProcedure)
 
db.CloseConnection()
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DataHelper Class
DataHelper Members
Overload List