Lists of objects of the same type are stored in a generic CSList<> class. The CSList<> type fully implements the ICollection and IList interfaces, as well as IBindingList. This means they can be bound to several data sources such as grids.
There are three ways to read a list of objects:
Examples:
CSList<Order> orders1 = Order.List(); CSList<Order> orders2 = Order.List("Date=@Today","@Today", DateTime.Today); CSList<Order> orders3 = Order.OrderedList("Date","Customer=@Customer", "@Customer", selectedCustomer); CSList<Order> orders4 = new CSList<Order>("Date=@Today", "@Today", DateTime.Today);
Once you have a CSList of objects, you can sort or filter the list using the FilteredBy() and OrderedBy() methods. Both methods return a new CSList. This is especially useful if you want to filter a list returned by an object's ManyToOne relation.
For example:
Customer customer = Customer.Read(100); // Read customer with ID 100 CSList<Order> customerTodayOrders = customer.Orders.FilteredBy("Date=@Today", "@Today", DateTime.Today); // customerTodayOrders contains a list of taday's orders for this customer
An explanation of the query expressions used in these examples can be found in the chapter on Query Expressions.
Vici CoolStorage allows you to read a specific range of records. The filtering is done on the database server, so only the needed records are read from the database.
For example, if we want to read customer records from record 11 to 20 (10 records):
CSList<Customer> customers = Customer.List().OrderedBy("Name").Range(11,10);