Siaqodb supports storing objects transactionally. The following classes will be used for this example:

public class Invoice
{
    public int Number { get; set; }
    public int CustomerId { get; set; }
    public Guid ID { get; set; }
    public int OID { get; set; }
}

public class InvoiceDetail
{
    public Guid InvoiceID { get; set; }
    public decimal UnitPrice { get; set; }
    public int Quantity { get; set; }
    public int OID { get; set; }
}

In this example it can be critical that when an invoice is stored, the associated InvoiceDetail objects are also stored. This can be accomplished using a Transaction:

ITransaction transaction = siaqodb.BeginTransaction();
Log("Start transactional operation");
try
{
    Invoice inv = new Invoice { Number = 1, CustomerId = 10, ID = Guid.NewGuid() };
    siaqodb.StoreObject(inv, transaction);
    for (int i = 1; i < 10; i++)
    {
        InvoiceDetail detail = new InvoiceDetail { InvoiceID = inv.ID, UnitPrice = i, Quantity = i % 3 };
        siaqodb.StoreObject(detail, transaction);
    }
    transaction.Commit();
    Log("Transaction Commit() successfully!");
}
catch (Exception ex)
{
    Log("There was a problem during transaction, Rollback all changes...");
    transaction.Rollback();
}

Optimization Considerations

Siaqodb uses transactions internally for each call to StoreObject and StoreObjectPartially. This makes each call commit records and index updates to the database. This is normally not a problem, however if you application needs to update many records at once, then a transaction will improve your performace considerably. The following example shows the use of a transaction for bulk updates (note, these examples are using the SiaqodbFactory class found on this page).

var sqo = SiaqodbFactory.GetInstance();
var transaction = sqo.BeginTransaction();
List<Invoice> itemsAdded = new List<Invoice>();
for (int i = 0; i < 500; i++)
{
    Invoice inv = new Invoice { Number = 1, CustomerId = 10, ID = Guid.NewGuid() };
    itemsAdded.Add(inv);
    sqo.StoreObject(inv, transaction);
}
transaction.Commit();
....

var transaction2 = sqo.BeginTransaction();
foreach(var inRec in itemsAdded)
{
    inRec.CustomerId = 11;
    sqo.StoreObjectPartially(inv, true, transaction, "CustomerId");  // Transaction support added in Siaqodb v5.5.0.9
}
transaction2.Commit();