FireDAC.Comp.DataSet.TFDDataSet.KeyFieldCount
Delphi
property KeyFieldCount: Integer read GetKeyFieldCount write SetKeyFieldCount;
C++
__property int KeyFieldCount = {read=GetKeyFieldCount, write=SetKeyFieldCount, nodefault};
Contents
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | public | FireDAC.Comp.DataSet.pas FireDAC.Comp.DataSet.hpp |
FireDAC.Comp.DataSet | TFDDataSet |
Description
Controls the number of indexed field values to use for key search or range setup.
Use KeyFieldCount to get or set the number of indexed field values to use for key searching or ranges setup. The default value is all indexed fields.
The KeyFieldCount must be less than or equal to the number of indexed fields (IndexFieldCount). If specified, then FireDAC uses the first KeyFieldCount indexed fields for searching, instead of IndexFieldCount fields. Setting KeyFieldCount is possible only in dsSetKeyMode
.
The property has meaning only for non-expressional indexes.
Example
//Example 1
FDQuery1.IndexFieldNames := 'EmployeeID;CustomerID;SellDate';
FDQuery1.SetKey;
FDQuery1.KeyFieldCount := 2;
FDQuery1.FieldByName('EmployeeID').AsInteger := 100;
FDQuery1.FieldByName('CustomerID').AsInteger := 200;
FDQuery1.GotoKey;
//Example 2
FDQuery1.IndexFieldNames := 'EmployeeID;CustomerID;SellDate';
FDQuery1.SetRangeStart;
FDQuery1.KeyFieldCount := 1;
FDQuery1.FieldByName('EmployeeID').AsInteger := 100;
FDQuery1.SetRangeEnd;
FDQuery1.KeyFieldCount := 1;
FDQuery1.FieldByName('EmployeeID').AsInteger := 100;
FDQuery1.ApplyRange;