Knight Data Access Layer
LoadPage(PagingParameters) Method
Example 




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > LoadPage Method : LoadPage(PagingParameters) Method
Get a page of records for a table
Syntax

Parameters

pagingParameters
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);
 
PagingParameters pagingParameters = new PagingParameters();
pagingParameters.TableName = "Person";
pagingParameters.PrimaryKeyName = "PersonId";
pagingParameters.WhereClause = "WHERE LastName <> @LastName";
pagingParameters.Parameters = new Dictionary<string, object>
                                  {
                                      {"@LastName", "Organa"}
                                  };
 
pagingParameters.OrderByClause = "ORDER BY FirstName";
pagingParameters.PageNumber = 2;
pagingParameters.PageSize = 2;
 
List<Dictionary<string, object>> list = db.LoadPage(pagingParameters);
 
// 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 pagingParameters As New PagingParameters()
pagingParameters.TableName = "Person"
pagingParameters.PrimaryKeyName = "PersonId"
pagingParameters.WhereClause = "WHERE LastName <> @LastName"
'INSTANT VB TODO TASK: Assignments within expressions are not supported in VB
'ORIGINAL LINE: pagingParameters.Parameters = New Dictionary(Of string, object) { {"@LastName", "Organa"} };
pagingParameters.Parameters = New Dictionary(Of String, Object) From {{"@LastName", "Organa"}}
 
pagingParameters.OrderByClause = "ORDER BY FirstName"
pagingParameters.PageNumber = 2
pagingParameters.PageSize = 2
 
Dim list As List(Of Dictionary(Of String, Object)) = db.LoadPage(pagingParameters)
 
' 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

IDataHelper Interface
IDataHelper Members
Overload List