I have a Dataset i want to apply a filter based on a dataset-type field record count, something like: 'NESTED_DATASET_FIELD.RecordCount > 0'
If the dataset comes from a SQL based storage engine, use a select distict query on the joined table with only fields from the master table in the result set. Let the SQL engine do the work for you.
Depending on your situation, you can use:
In
OnFilterRecord
event you can have:Accept := myDataSetField.NestedDataSet.RecordCount>0;
If you have a SQL backend you can use the
Exists
orCount
in order to fetch only the records which you need. Perhaps is the best approach if you are over a network. However I don't know what infrastructure you have.In
OnFilterRecord
event you can have:Accept := not myDataSetField.IsNull; //Just testing if the DataSet field is empty - which is one of the fastest ways to do it ...but this depends on the structure of your data / dataset etc.
Sometimes is better to have a dedicated field in your DataSet / Table to specify this status because usually getting such info from the nested dataset can be expensive. (One must fetch it at least partially etc.)
Also, for the same considerations (see 4. above) perhaps you can have a Stored Procedure (if your DB backend permits) to get this info.
HTH