Ninja Database Pro
DataFormat Property
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : DataFormat Property
The data format for saving objects. The default is plain binary.
Syntax
Public Property DataFormat As EncodingFormat
Dim instance As NinjaDbPro
Dim value As EncodingFormat
 
instance.DataFormat = value
 
value = instance.DataFormat
public EncodingFormat DataFormat {get; set;}
public:
property EncodingFormat DataFormat {
   EncodingFormat get();
   void set (    EncodingFormat value);
}
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();  
             
            //Save everything compressed
            db.DataFormat = EncodingFormat.Compressed;
             
            db.OpenDatabase();
             
            Person person1 = new Person();
            person1.DateCreated = DateTime.Now;
            person1.Name = "John Smith";
            db.Save(person1);
             
            db.CloseDatabase();
             
            //Save everything encrypted
            db.EncryptionPassword = "topsecret";
            db.EncryptionSalt = "ThisIsASalt"; 
            db.DataFormat = EncodingFormat.Encrypted;
             
            db.OpenDatabase();
             
            Person person2 = new Person();
            person2.DateCreated = DateTime.Now;
            person2.Name = "Jane Smith";
            db.Save(person2);
             
            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();  
             
            'Save everything compressed
            db.DataFormat = EncodingFormat.Compressed
             
            db.OpenDatabase()
             
            Dim person1 As New Person()
            person1.DateCreated = Date.Now
            person1.Name = "John Smith"
            db.Save(person1)
             
            db.CloseDatabase()
             
            'Save everything encrypted
            db.EncryptionPassword = "topsecret"
            db.EncryptionSalt = "ThisIsASalt"
            db.DataFormat = EncodingFormat.Encrypted
             
            db.OpenDatabase()
             
            Dim person2 As New Person()
            person2.DateCreated = Date.Now
            person2.Name = "Jane Smith"
            db.Save(person2)
             
            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