-
Notifications
You must be signed in to change notification settings - Fork 26
hs550
In order to work with business objects they have to be retrieved into memory. Specific objects can be retrieved via the Retrieve constructor of their class if their object Id is known. If this is not the case or if multiple objects need to be accessed at once, either for presentation or manipulation, they can be selected from the database.
Objects are selected from the database via theTInstantSelector component. This component is a special exposer that allows you to specify a command that defines the objects to be retrieved and optionally exposed. The syntax of the command is somewhat similar to SQL, but instead of tables and columns, you specify classes and attributes. When opened, TInstantSelector queries the database for the corresponding objects and exposes those as rows in the dataset. In addition, the selected objects are available via the Objects array property of the selector. See the section Exposing Objects for details about exposing.
In its simplest form, the selector command looks like this:
SELECT * FROM TPerson
The above command will select all objects of the TPerson class. By adding a WHERE clause and an ORDER BY clause, the selection is limited to objects meeting a certain criteria and sorted as well:
Attributes are specified using regular dot-notation. This allows you to specify attributes of the selected object and objects related to thisobject. Please consult the InstantObjects Reference Guide for an in-depth explanation of the TInstantSelector Command property.
TInstantSelector is being used in the contact book in several areas.First of all, the main contact grid used for browsing contacts is connected via a TDataSource to a selector. The command of this selector is changed when clicking one of the index-tabs above the grid and when performing a search via the Find feature.
In TContactEditForm, The country and category fields of a contact are edited via a standard TDBLookupComboBox in which the drop down list is connected to a selector that is exposing the objects that can be associated with the field.
All forms used for browsing and looking up objects descent from TBasicBrowseForm. These forms all use a selector to select and expose the desired objects.
- Home
- Glossary
- Project structure
- Installing InstantObjects
- User Guide for InstantObjects
- Creating the Business Model
- Creating the User Interface
- Programming with Persistent Objects
- Learning the Primer Demo