Persistate

Collections of selected objects

Hide Navigation Pane

Collections of selected objects

Previous topic Next topic No directory for this topic  

Collections of selected objects

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

When you define a collection of selected objects, Persistate generates a public collection property to access the member objects, along with a private collection field to actually hold the objects.  Like all collections, the type of selected collection properties is IndexedList<T>.  However, with selected collections, before you can access objects in the collection, you must perform the selection.

Persistate generates a single method to perform this selection.  This method will be named

Select<collection plural name>

So for example, for the MonthlyLendStatistics collection of the Library singleton, the method will be called SelectMonthlyLendStatistics.  The type of a selected collection must be a view class.  The names and types of the parameters of the generated method will correspond to the parameters in the view class definition.

If you look at the monthly lend statistic view class in An Example Definition File, you will see that it has two parameters called from and to, both compared to datetime members.  The SelectMonthlyLendStatistics method therefore has two datetime parameters called from and to.  Here is an example of using this method.  This gets the numbers of lends per genre in the current month, and finds genres below a certain threshold.

List<string> genreNames = new List<string>();
IndexedList<MonthlyLendStatistic> statistics
   = The.Library.SelectMonthlyLendStatistics(monthStartDateTime.Now);
foreach (MonthlyLendStatistic statistic in statistics)
   if (statistic.LendCount < threshold)
      genreNames.Add(statistic.Name);