Lists all client indexes that apply to the dataset.
Use Indexes to define client side data views on the dataset records. Indexes are a collection of the TADIndex objects, each of them defines optional:
The individual indexes are not just the sort and filter definitions. AnyDAC maintains a consistent view on the data for each active index, while application fetches data or edits data. That creates additional overhead, but allows to switch between indexes without delays.
Dataset maintains Indexes views, when IndexesActive is True. When an application needs to perform batch updates to dataset, then set IndexesActive to False before updates, and return to original value after updates. Also see BeginBatch / EndBatch methods.
Setting IndexFieldNames does not add a TADIndex object to Indexes collection. Defining IndexDefs before dataset opening, will clear Indexes and fill them using IndexDefs information. So, there are two alternative ways - use IndexDefs or use Indexes. We suggest to use Indexes, as it is more flexible.
The sorting and filter expressions in Indexes supports syntax compatible with:
with ADMemTable1.Indexes.Add do begin Name := 'by_name'; Fields := 'NAME;DT'; Active := True; end; with ADMemTable1.Indexes.Add do begin Name := 'by_payments'; Expression := 'sum(sal + bonus)'; Filter := 'dep_id is not null; Active := True; end; ADMemTable1.IndexesActive := True; ADMemTable1.IndexName := 'by_name';
See AnyDAC\Samples\Comp Layer\TADQuery\Indices demo for details.
What do you think about this topic? Send feedback!