示例#1
0
        private static void CRUD_POCO(Siaqodb siaqodb)
        {
            //register key convention, so we can work directly with POCO
            SiaqodbConfigurator.RegisterKeyConvention <Invoice>(a => a.Id);

            IBucket bucket = siaqodb.Documents["invoices"];

            Invoice invoice = BuildInvoice();

            //insert
            bucket.Store(invoice);

            Invoice invoiceLoaded = bucket.Load <Invoice>(invoice.Id);

            invoiceLoaded.InvoiceDate = invoiceLoaded.InvoiceDate.AddDays(-1);
            //update
            bucket.Store(invoiceLoaded);
            //delete
            bucket.Delete(invoiceLoaded.Id);
        }
示例#2
0
        private static void CRUD_Document(Siaqodb siaqodb)
        {
            IBucket bucket = siaqodb.Documents["invoices"];

            Invoice invoice = BuildInvoice();
            //insert
            Document doc = new Document();

            doc.Key = invoice.Id;
            doc.SetContent <Invoice>(invoice);

            bucket.Store(doc);

            Document documentLoaded = bucket.Load(invoice.Id);
            Invoice  invoiceLoaded  = documentLoaded.GetContent <Invoice>();

            invoiceLoaded.InvoiceDate = invoiceLoaded.InvoiceDate.AddDays(-1);
            documentLoaded.SetContent <Invoice>(invoiceLoaded);
            //update
            bucket.Store(documentLoaded);
            //delete
            bucket.Delete(documentLoaded);
        }