Ninja Database Pro
LoadAll<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : LoadAll<T> Method
Load the entire list of an object type from the database ordered by the primary key Children and parents are not loaded. To load children and parents do a LoadAllWithChildren If there is nothing found, an empty list is returned.
Syntax
Public Function LoadAll(Of T As {Class, New})() As List(Of T)
Dim instance As NinjaDbPro
Dim value As List(Of T)
 
value = instance.LoadAll(Of T)()
public List<T> LoadAll<T>()
where T: class, new()
public:
List<T^>^ LoadAllgeneric<typename T>
(); 
where T: ref class, gcnew()

Type Parameters

T
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);
             
            List<Person> personsCopy = db.LoadAll<Person>();
             
            db.CloseDatabase();
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)
             
            Dim personsCopy As List(Of Person) = db.LoadAll(Of Person)()
             
            db.CloseDatabase()
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