Knight Data Access Layer
LoadPage<T>(Int32,Int32) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > DataHelper Class > LoadPage Method : LoadPage<T>(Int32,Int32) Method
Generic class type
Page of records starting at 1
The number of records to get per page
Load a page of records
Syntax
Public Overloads Function LoadPage(Of T As {Class, New})( _
   ByVal page As Integer, _
   ByVal pageSize As Integer _
) As List(Of T)
Dim instance As DataHelper
Dim page As Integer
Dim pageSize As Integer
Dim value As List(Of T)
 
value = instance.LoadPage(Of T)(page, pageSize)
public List<T> LoadPage<T>( 
   int page,
   int pageSize
)
where T: class, new()
public: List<T*>* LoadPage<T>( 
   int page,
   int pageSize
) 
where T: ref class, gcnew()
public:
List<T^>^ LoadPagegeneric<typename T>
( 
   int page,
   int pageSize
) 
where T: ref class, gcnew()

Parameters

page
Page of records starting at 1
pageSize
The number of records to get per page

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==";
 
// Open the database connection
db.OpenConnection();
 
// Clear table Person
db.TruncateTable("Person");
 
// Create Persons to save to the database
List<Person> persons = new List<Person>
                           {
                               new Person
                                   {
                                       FirstName = "Han",
                                       LastName = "Solo"
                                   },
                               new Person
                                   {
                                       FirstName = "Luke",
                                       LastName = "Skywalker"
                                   },
                               new Person
                                   {
                                       FirstName = "Leia",
                                       LastName = "Organa"
                                   },
                               new Person
                                   {
                                       FirstName = "Obi-Wan",
                                       LastName = "Kenobi"
                                   },
                               new Person
                                   {
                                       FirstName = "Padme",
                                       LastName = "Amidala"
                                   },
                           };
 
// Save them to the database 
db.Save(persons);
 
var result = db.LoadPage<Person>(2, 2);
 
// Close the connection
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()
 
' Clear table Person
db.TruncateTable("Person")
 
' Create Persons to save to the database
Dim persons As New List(Of Person)() From {
    New Person With {.FirstName = "Han", .LastName = "Solo"},
    New Person With {.FirstName = "Luke", .LastName = "Skywalker"},
    New Person With {.FirstName = "Leia", .LastName = "Organa"},
    New Person With {.FirstName = "Obi-Wan", .LastName = "Kenobi"},
    New Person With {.FirstName = "Padme", .LastName = "Amidala"}}
 
' Save them to the database 
db.Save(persons)
 
Dim result = db.LoadPage(Of Person)(2, 2)
 
' Close the connection
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