Containers

 

Database supports containers for dynamic objects. Containers allow storing dynamic objects by groups e.g. “electronics”, “furniture”

Containers were designed as fully isolated storages for dynamic objects. The same object can be stored in 2 or more containers, and the changes to the object in one container will leave the copy of the same object in another container unchanged.

Example:

const string db_name = "Test";

DB db = new DB("server=(local);password=pwd;options=none;");

db.DeleteDatabase(db_name, true);

db.CreateDatabase(db_name);

db.OpenDatabase(db_name);

db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;

 

db.Containers.CreateContainer("Electronics");

var electronics = db.Containers["Electronics"];

 

Dynamic tv = new Dynamic();

tv["Price"] = 649;//dollars

tv["Model"] = "Samsung LA40C650";

tv["Screen"] = 6.40;//inch

 

electronics.Store(tv);

 

db.Containers.CreateContainer("Furniture");

var furniture = db.Containers["Furniture"];

 

Dynamic bed = new Dynamic();

bed["Price"] = 700;//dollars

bed["Type"] = "King";

 

furniture.Store(bed);

 

var beds = furniture.ExecuteQuery("SELECT Dynamic WHERE Price > 600");

 

var tvs = from Dynamic d in electronics where d["Model"] == "Samsung LA40C650" select d;

db.Close();

 

Storing Parent object will store its Children objects into in the same container

Get list of all containers in the database

 

To get list of all existing containers the following API can be used

// Get a list of containers.

string[] containerList = db.Containers.ListContainers();