Ninja Database Pro
RollbackTransaction Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : RollbackTransaction Method
Undo all actions in a transaction. Do a BeginTransaction to start the transaction. Do a CommitTransaction to permanantly save the actions. If the Phone or PC loses power during a transaction it will automatically be rolled back on OpenDatabase.
Syntax
Public Sub RollbackTransaction() 
Dim instance As NinjaDbPro
 
instance.RollbackTransaction()
public void RollbackTransaction()
public:
void RollbackTransaction(); 
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();  
             
            Person person1 = new Person();
            person1.Name = "John";
             
            Person person2 = new Person();
            person2.Name = "Jane";
             
            db.OpenDatabase();
             
            //These two persons will be saved as a group and then rolled back as a group
            db.BeginTransaction();
            db.Save(person1);
            db.Save(person2);
            db.RollbackTransaction();
             
            //This will be null because it was rolled back
            Person person1Copy = db.Load<Person>(person1.PersonId);
             
            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();  
             
            Dim person1 As New Person()
            person1.Name = "John"
             
            Dim person2 As New Person()
            person2.Name = "Jane"
             
            db.OpenDatabase()
             
            'These two persons will be saved as a group and then rolled back as a group
            db.BeginTransaction()
            db.Save(person1)
            db.Save(person2)
            db.RollbackTransaction()
             
            'This will be null because it was rolled back
            Dim person1Copy As Person = db.Load(Of Person)(person1.PersonId)
             
            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