Key Concepts

There are two aspects to a DataStore: The Data Model, the definition of how the data is to be modelled in terms of ItemTypes , AttributeTypes , and AssociationTypes. ; and the data itself Items , Attributes , and Associations.

DataStores are accessed through Connections.

Connection

Represents a connection to a DataStore.

In the two examples it is assumed that the variable orderProcessing holds the string "Orderprocessing.ds".

A Connection is obtained when a DataStore is created:

Connection orderProcessing = Instance.Create(orderProcessingPath, "OrderProcessingDataStore");

Instance.Create creates a new DataStore, and returns a Connection to it that is stored in the variable orderProcessing. The filename of the created DataStore is "Orderprocessing.ds". The name of the DataStore is "OrderProcessing"

or when it is opened:

Connection orderProcessing = Instance.Open(orderProcessingPath);

Instance.Open opens an existing DataStore, in a file named "Orderprocessing.ds", and returns a Connection to it that is stored in the variable orderProcessing.

Item Type

Defines the information that can be held against an Item: Its Attributes, and the other Items with which it can form an Association. Each Item Type has a name.

ItemType productType = orderProcessing.AddItemType("Product", "", "");

Connection.AddItemType creates a new ItemType in the DataStore referenced by the Connection orderProcessing. The name of the ItemType is "Product" and a reference to it is stored in the variable productType.

Attribute Type

Defines a value that an Item can have. Attribute Types have a name and a Value Type.

productType.AddAttributeType("Description", "", "", ValueType.String);

ItemType.AddAttributeType creates a new AtributeType for the ItemType referenced by the variable productType. The name of the AtributeType is "Description", and it can take values of type String.

Association Type

Defines the Associations that an Item can make. The AssociationType has a name and defines a set of other ItemTypes. An Association of this type can be with any Item of one of the types in the set.

productType.AddAssociationType("OrderedOn", "", "", orderLineType, "For", "", "");

ItemType.AddAssociationType allows Associations to be made between Items of the ItemType referenced by the variable productType, and Items of the ItemType referenced by the variable orderLineType. The ItemType referenced by the variable productType will have an AssociationType named "Ordered On". The ItemType referenced by the variable orderLineType will have an AssociationType named "For". In other words: Products are "Ordered On" OrderLines, OrderLines are "For" Products.

Item

An instance of an ItemType can have Attributes and Associations as defined by its ItemType.

Items can be created,

Item product = productType.CreateItem();

and deleted.

product.Delete();

Attribute

Attributes can be set,

product.SetAttribute("Code", "P0001");

and got.

string code = (string)product.GetAttribute("Code");

Association

An association between two items.

Associations can be added,

orderLine.AddAssociation("For", product);

and removed.

orderLine.RemoveAssociation("For", product);

The set of Items associated with an Item, for a given Association Type, can be retrieved.

Iterator<Item> orderLineIterator = product.GetAssociations("OrderedOn");
while (!orderLineIterator.GetDone())
{
    Console.WriteLine("Order:" + orderLineIterator.GetCurrent().GetAssociations("On").GetCurrent().GetAttribute("OrderNo"));
    orderLineIterator.Next();
}

This website stores cookies on your computer that are used to manage the order in which you see the pages. To find out more about the cookies we use, see our Privacy Policy.