If you prefer to work mostly with POCO (Plain Old CLR Object) objects rather than with Documents, Siaoqdb provides some facilities to not pass back and forth Document.Key and/or Document.Version.

Usually if you want to update a Document, besides the Key and Document properties, you must set also the Version so server(see SiaqodbCloud) is able to check about optimistic concurrency.

For example if you call:

 Invoice inv = bucket.Load<Invoice>("Invoice-324r");

And you do some changes to the 'inv' object and then you want to save it back (considering that you are using SiaqodbCloud to Sync the buckets), at this moment you will have to pass also the Version for Document, otherwise you will get a Conflict error on Sync.

To avoid this, you can register some convention and embed necessary properties into our POCO definition.

So we'll modify class definition for Invoice like this:

public class Invoice
    public string Id { get; set; }
    public string Version{ get; set; }
    public string CustomerName { get; set; }
    public int InvoiceNumber { get; set; }
    public decimal Total { get; set; }
    public DateTime InvoiceDate { get; set; }

And then we'll register some conventions, so when a Document is read/written, it links Document.Key with Invoice.Id and Document.Version with Invoice.Version:

SiaqodbConfigurator.RegisterKeyConvention<Invoice>(a => a.Id);
SiaqodbConfigurator.RegisterSetVersionConvention<Invoice>(a => a.Version);

(If you don't use SiaqodbCloud and Sync then you can skip the conventions for Version).

So from now on, you can simply Read and Write POCO objects like this:

Invoice inv = bucket.Load<Invoice>("Invoice-324r");