Ninja Database Pro
RowCount<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : RowCount<T> Method
Count all objects of a specific type
Syntax
Public Function RowCount(Of T As {Class, New})() As Integer
Dim instance As NinjaDbPro
Dim value As Integer
 
value = instance.RowCount(Of T)()
public int RowCount<T>()
where T: class, new()
public:
int RowCountgeneric<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();
             
            Person person1 = new Person();
            person1.DateCreated = DateTime.Now;
            person1.Name = "Greg1";
            db.Save(person1);
             
            Person person2 = new Person();
            person2.DateCreated = DateTime.Now;
            person2.Name = "Greg2";
            db.Save(person2);
             
            //Get the number of person records
            int rowCount = db.RowCount<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 person1 As New Person()
            person1.DateCreated = Date.Now
            person1.Name = "Greg1"
            db.Save(person1)
             
            Dim person2 As New Person()
            person2.DateCreated = Date.Now
            person2.Name = "Greg2"
            db.Save(person2)
             
            'Get the number of person records
            Dim rowCount As Integer = db.RowCount(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