Knight Data Access Layer
LoadTop<T>(String,Dictionary<String,Object>,String,Int32) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > LoadTop Method : LoadTop<T>(String,Dictionary<String,Object>,String,Int32) Method
Generic class type
A SQL where clause
Parameters for the where clause
Order by SQL Clause
Number of records to retrieve
Load Top N Records filtered by a Where clause that are ordered
Syntax
Overloads Function LoadTop(Of T As {Class, New})( _
   ByVal whereClause As String, _
   ByVal parameters As Dictionary(Of String,Object), _
   ByVal orderBy As String, _
   ByVal records As Integer _
) As List(Of T)
Dim instance As IDataHelper
Dim whereClause As String
Dim parameters As Dictionary(Of String,Object)
Dim orderBy As String
Dim records As Integer
Dim value As List(Of T)
 
value = instance.LoadTop(Of T)(whereClause, parameters, orderBy, records)
List<T> LoadTop<T>( 
   string whereClause,
   Dictionary<string,object> parameters,
   string orderBy,
   int records
)
where T: class, new()
List<T*>* LoadTop<T>( 
   string* whereClause,
   Dictionary<string*,Object*>* parameters,
   string* orderBy,
   int records
) 
where T: ref class, gcnew()
List<T^>^ LoadTopgeneric<typename T>
( 
   String^ whereClause,
   Dictionary<String^,Object^>^ parameters,
   String^ orderBy,
   int records
) 
where T: ref class, gcnew()

Parameters

whereClause
A SQL where clause
parameters
Parameters for the where clause
orderBy
Order by SQL Clause
records
Number of records to retrieve

Type Parameters

T
Generic class type
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==";
 
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Stan','Man')");
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Dan','Man')");
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Dan','Abel')");
 
Dictionary<string,object> parameters = new Dictionary<string, object>();
parameters.Add("@FirstName", "Dan");
List<Person> list = db.LoadTop<Person>("WHERE FirstName = @FirstName", parameters, "ORDER BY LastName",1);
'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=="
 
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Stan','Man')")
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Dan','Man')")
db.ExecuteNonQuery("INSERT INTO Person (FirstName,LastName) VALUES ('Dan','Abel')")
 
Dim parameters As New Dictionary(Of String,Object)()
parameters.Add("@FirstName", "Dan")
Dim list As List(Of Person) = db.LoadTop(Of Person)("WHERE FirstName = @FirstName", parameters, "ORDER BY LastName",1)
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

IDataHelper Interface
IDataHelper Members
Overload List