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




KellermanSoftware.NetDataAccessLayer Namespace > IDataHelper Interface > LoadPageWithChildren Method : LoadPageWithChildren<T>(String,Dictionary<String,Object>,String,Int32,Int32) Method
Generic class type
A SQL where clause
The parameters to use for the where clause
Order by SQL Clause
Page of records starting at 1
The number of records to get per page
Load a page of records with children that are filtered by a where clause and ordered
Syntax
Overloads Function LoadPageWithChildren(Of T As {Class, New})( _
   ByVal whereClause As String, _
   ByVal parameters As Dictionary(Of String,Object), _
   ByVal orderBy As String, _
   ByVal page As Integer, _
   ByVal pageSize 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 page As Integer
Dim pageSize As Integer
Dim value As List(Of T)
 
value = instance.LoadPageWithChildren(Of T)(whereClause, parameters, orderBy, page, pageSize)
List<T> LoadPageWithChildren<T>( 
   string whereClause,
   Dictionary<string,object> parameters,
   string orderBy,
   int page,
   int pageSize
)
where T: class, new()
List<T*>* LoadPageWithChildren<T>( 
   string* whereClause,
   Dictionary<string*,Object*>* parameters,
   string* orderBy,
   int page,
   int pageSize
) 
where T: ref class, gcnew()
List<T^>^ LoadPageWithChildrengeneric<typename T>
( 
   String^ whereClause,
   Dictionary<String^,Object^>^ parameters,
   String^ orderBy,
   int page,
   int pageSize
) 
where T: ref class, gcnew()

Parameters

whereClause
A SQL where clause
parameters
The parameters to use for the where clause
orderBy
Order by SQL Clause
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.LoadPageWithChildren<Person>("WHERE LastName <> @LastName",
                                  new Dictionary<string, object>
                                      {
                                        { "@LastName", "Organa" }
                                      },
                                  "ORDER BY FirstName",
                                  2,
                                  2);
 
result = db.LoadPageWithChildren<Person>("FirstName <> @FirstName",
                              new Dictionary<string, object>
                                  {
                                      { "@FirstName", "Han" }
                                  },
                              "LastName",
                              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)
 
'INSTANT VB TODO TASK: Assignments within expressions are not supported in VB
'ORIGINAL LINE: var result = db.LoadPageWithChildren(Of Person)("WHERE LastName <> @LastName", New Dictionary(Of string, object) { { "@LastName", "Organa" } }, "ORDER BY FirstName", 2, 2);
Dim result = db.LoadPageWithChildren(Of Person)("WHERE LastName <> @LastName", New Dictionary(Of String, Object) From {{ "@LastName", "Organa" }}, "ORDER BY FirstName", 2, 2)
 
'INSTANT VB TODO TASK: Assignments within expressions are not supported in VB
'ORIGINAL LINE: result = db.LoadPageWithChildren(Of Person)("FirstName <> @FirstName", New Dictionary(Of string, object) { { "@FirstName", "Han" } }, "LastName", 2, 2);
result = db.LoadPageWithChildren(Of Person)("FirstName <> @FirstName", New Dictionary(Of String, Object) From {{ "@FirstName", "Han" }}, "LastName", 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

IDataHelper Interface
IDataHelper Members
Overload List