FireDAC.Comp.DataSet.TFDIndex

From RAD Studio API Documentation
Jump to: navigation, search

System.Classes.TCollectionItemSystem.Classes.TPersistentSystem.TObjectTFDIndex

Delphi

TFDIndex = class (TCollectionItem)

C++

class PASCALIMPLEMENTATION TFDIndex : public System::Classes::TCollectionItem

Properties

Type Visibility Source Unit Parent
class public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet FireDAC.Comp.DataSet

Description

TFDIndex represents a maintained client view for records in a FireDAC dataset.

Use TFDIndex to create and maintain client views for records in a FireDAC dataset.

TFDIndex are gathered into the TFDIndexes collection. The set of TFDIndex can be created at design time, as well as at runtime.

The Fields property specifies the list of sort fields. Alternatively, the Expression property specifies the sort expression. The Filter property specifies the filtering expression. The view is maintained if Active and IndexesActive are True.

The view becomes current in the dataset if Selected is True or IndexName is set to the name of this view.

Note: The name may confuse you. It talks about "index". Originally, TFDIndex represented a maintained index, but later we have added extended features to TFDIndex, so it is not just controlling sorting order. It is possible to define indexes using IndexDefs. But we recomnend using Indexes. It offers more options, while IndexDefs is for compatibility with legacy software.

Example

ADQuery1.IndexesActive := True;
ADQuery1.Open;

with ADQuery1.Indexes.Add do begin
  Name := 'Orders';
  Fields := 'ORDER_NO;PART_NO';
  Filter := 'OrderDate < ''01.01.2008''';
  Active := True;
  Selected := True;
end;

See Also