Persistate

The persistent tree

Hide Navigation Pane

The persistent tree

Previous topic Next topic No directory for this topic  

The persistent tree

Previous topic Next topic Topic directory requires JavaScript JavaScript is required for the print function Mail us feedback on this topic!  

The object classes in the definition file that you write define the structure of the persistent object tree used by your package.  See Object Class Definition for more details.  The root objects in this tree are the singleton object classes that you define in your file - often you will have only one of these.  Let us take the example of the library application shown in An Example Definition File.  The persistent tree for the library package looks like this.  This tree has a single singleton root object - the Library object.  Note that this structure above shows only the containment structure - it does not show any associated links between objects.

The persistent tree in the Library package

The persistent tree in the Library package

A singleton object is your "way in" into the persistent object graph.  You define them with object class definitions starting with The in place of Each.  Using singletons is very easy. Persistate generates a class called The in your package, in which it creates a static property for every singleton.  So to access the singleton library object in code, all you need is the following.

The.Library

Persistate automatically creates all singleton objects for you.  Everything else you have to create yourself - but that's easy, see Creating objects for details.  Accessing objects further down the tree is also easy.  Here are some examples.  All the methods used below are generated from the example definition file - how they work will be explained in subsequent topics.

IPersistateList authors = The.Library.AuthorsWithSurname("Rankin");
Publication publication = The.Library.PublicationWithIsbnNumber(isbn);
foreach (Lend lend in The.Library.LendsWithPublication(publication)) {
int johnSmiths = The.Library.BorrowersLike("John", "Smith").Count;
Genre genre = The.Library.Genres["Biography"];
return The.Library.SelectMonthlyLendStatistics(monthStart, DateTime.Now);

You can see from the above examples that accessing persistent data is very straightforward, and does not involve any API calls - only calls to business level methods that Persistate generates for you.  This illustrates one of Persistate's key features.  Persistate turns C# into a language for programming persistent objects directly.