Siaqodb has a very simple API for CRUD operations. You can Create, Retrieve, Update and Delete database objects with just one line of code.

First define the class for operations:

public class Employee
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime HireDate { get; set; }
    public int Age { get; set; }
    public int OID { get; set; }
}

Now create, update and delete an object in the Siaqodb database (note, these examples are using the SiaqodbFactory class found on this page):

Siaqodb siaqodb = SiaqodbFactory.GetInstance();
Employee employee = new Employee();
employee.FirstName = "John";
employee.LastName = "Walter";
employee.Age = 31;
employee.HireDate = new DateTime(2008, 10, 12);
//insert will occur
siaqodb.StoreObject(employee);
employee.Age = 32;
//update will occur
siaqodb.StoreObject(employee);
//delete will occur
siaqodb.Delete(employee);

Siaqodb CRUD operations are elegantly simple!

Siaqodb handles nested objects in CRUD operations elegantly as well. We will define a new Company class and add a Company property to the existing Employee class:

public class Company
{
    public string Name { get; set; }
    public string Address { get; set; }
    public string Phone { get; set; }
    public int OID { get; set; }
}
public class Employee
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime HireDate { get; set; }
    public int Age { get; set; }
    public Company Employer{get;set;}
    public int OID { get; set; }
}

Now we can create a Company object and assign it to the Employer property. When we then save the Employee object, the Siaqodb engine saves both the Employee and Employer as two separate database objects of type Employee and type Company respectively.

Siaqodb siaqodb = SiaqodbFactory.GetInstance();
Company company = new Company();
company.Name = "MyCompany";
Employee employee = new Employee();
employee.FirstName = "John";
employee.LastName = "Walter";
employee.Age = 31;
employee.HireDate = new DateTime(2008, 10, 12);
employee.Employer=company;

Create

//insert will occur and two objects will be inserted, first the company object and then the employee object
siaqodb.StoreObject(employee);

Update

if we do:

siaqodb.StoreObject(company);
siaqodb.StoreObject(employee);

When parent objects are stored, the parent is created or updated as before. The Siaqodb engine also automatically creates or updates all nested objects in the graph – regardless of the depth of the object graph.

Delete

However, when a parent object is deleted nested objects are not automatically deleted. For example calling:

siaqodb.Delete(employee);

will only delete the Employee. The Company referenced by the Employer property is not deleted.

As of version 5.5.0.10, if you do wish to remove nested objects, you can call Delete like so:

siaqodb.Delete(employee, true);

This call will automatically remove both the Employee object and the nested Company object (and if you had further nesting those objects would also be deleted; additionally any List of objects would also be deleted using this call). As expected, deleting and deleted events will be raied for both objects. Additionally, a transaction may be passed to this version of delete.

Delete All of a Type

If you are looking to delete the entire set of one type of object, you can do so in one call. For example calling:

siaqodb.DropType<Company>();

will remove all companies from the database.

Delete All Types

If you are looking to delete all sets of all types, you can do so in one call. For example calling:

siaqodb.DropAllTypes();

will remove all of your data - please use with caution!