Ninja Database Pro
LoadPage<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : LoadPage<T> Method
The type of object to load
The page number, starting at 1
The number of items for each page
If true it is loaded by ascending
Load a page of items ordered by the primary key
Syntax
Public Function LoadPage(Of T As {Class, New})( _
   ByVal pageNumber As Integer, _
   ByVal pageSize As Integer, _
   ByVal ascending As Boolean _
) As List(Of T)
Dim instance As NinjaDbPro
Dim pageNumber As Integer
Dim pageSize As Integer
Dim ascending As Boolean
Dim value As List(Of T)
 
value = instance.LoadPage(Of T)(pageNumber, pageSize, ascending)
public List<T> LoadPage<T>( 
   int pageNumber,
   int pageSize,
   bool ascending
)
where T: class, new()
public:
List<T^>^ LoadPagegeneric<typename T>
( 
   int pageNumber,
   int pageSize,
   bool ascending
) 
where T: ref class, gcnew()

Parameters

pageNumber
The page number, starting at 1
pageSize
The number of items for each page
ascending
If true it is loaded by ascending

Type Parameters

T
The type of object to load

Return Value

A page of items
Example
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName");
             
//Licensed Mode
//db.UserName = "John Smith 101224";
//db.LicenseKey = "aousdf832jasf==";
 
//Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are:
//db.Storage = new MemoryDatabase(); //In memory database
//db.Storage = new FileDatabase();  
 
db.OpenDatabase();
 
List<Person> persons = new List<Person>();
Person person1 = new Person();
person1.DateCreated = DateTime.Now;
person1.Name = "John";
persons.Add(person1);
 
Person person2 = new Person();
person2.DateCreated = DateTime.Now;
person2.Name = "Jane";
persons.Add(person2);
 
db.Save(persons);
 
//Only one person will be loaded since it is a page of 1
//This is loaded in ascending order by the primary key
List<Person> page1 = db.LoadPage<Person>(1, 1, true);
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName")
 
'Licensed Mode
'db.UserName = "John Smith 101224";
'db.LicenseKey = "aousdf832jasf==";
 
'Set before OpenDatabase. Default storage is IsolatedStorageDatabase. Other options are:
'db.Storage = new MemoryDatabase(); //In memory database
'db.Storage = new FileDatabase();  
 
db.OpenDatabase()
 
Dim persons As New List(Of Person)()
Dim person1 As New Person()
person1.DateCreated = Date.Now
person1.Name = "John"
persons.Add(person1)
 
Dim person2 As New Person()
person2.DateCreated = Date.Now
person2.Name = "Jane"
persons.Add(person2)
 
db.Save(persons)
 
'Only one person will be loaded since it is a page of 1
'This is loaded in ascending order by the primary key
Dim page1 As List(Of Person) = db.LoadPage(Of Person)(1, 1, True)
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

NinjaDbPro Class
NinjaDbPro Members