Mozilla Skin

Persistence

From Open Forex Platform Wiki

The Platform uses a compact SQLite database(s) as its primarily persistence data storage. With a special adapter dll to access and use it trough .NET System.Data.SQLite.

The persistence model applies a set of common helper classes (IDBPersistent, DBPersistent, ADOPersistenceHelper etc.) to implement a light automated persistence framework. It allows to store and access new classes and class members in the corresponding database tables without writing SQL queries. To map the class and members to database tables and columns, the DBPersistenceAttribute class is used.

Persistence example:


[DBPersistenceAttribute(true)] // Specify by default all members of class are mapped to database columns
class MyClass : DBPersistent
{
   [DBPersistenceAttribute(false)] // This member will not be mapped.
   public int Member1
   {
      get { ... }; set { ... };
   }

   [DBPersistenceAttribute(true)] // This member will always be mapped.
   public int Member2
   {
      get { ... }; set { ... };
   }

   [DBPersistenceAttribute(PersistenceModeEnum.ReadOnly)] // This member will be mapped as read only member - changes of it will not be updated to DB.
   public int Member3
   {
      get { ... }; set { ... };
   }

   [DBPersistenceAttribute(PersistenceTypeEnum.Binary)] // This member will be stored as binary representation in the DB.
   public int Member4
   {
      get { ... }; set { ... };
   }

   public int Member5 // This member will be mapped by default.
   {
      get { ... }; set { ... };
   }
}

The current (v.0.7) implementation of the Platform uses the following database tables in the ofxp.s3db database

  • Platforms table

Stores separate instances of a platform.

  • PlatformsComponents table

Stores components existing in the given platform. In the "Data" column is stored a binary representation of the custom data for the given component.

  • NewsSources table

Stores the news sources available to the given platform.

  • RssNewsItems table

Stores a history of the news items for the given news source. News items are deleted when their source is deleted.