Querying the data

Now we want to list all cost items:

PersistenceManager pm = new PersistenceManager();

Query q = pm.NewQuery(typeof(Employee));

Employee e = (Employee) q.ExecuteSingle();

Travel t = (Travel) e.Travels[0];

Console.WriteLine("Costs of the travel with the purpose " + t.Purpose + ":");

foreach(Expense ex in t.Expenses)

    Console.WriteLine(ex.Date.ToShortDateString() + " " + ex.Text + " " + ex.Amount.ToString());

The inherited and derived functions of the base class Expense allow us to display the objects of the different classes in the same way.