Apply filters without changing query intent

Completed

Query filters can define permanent selection rules or let a caller narrow a result for a specific operation. Their interaction matters: a runtime filter can replace one filter and intersect another.

Combine design-time filters

DataItemTableFilter applies to a data item and remains in effect when a caller adds a runtime filter. ColumnFilter applies to a query column. Use these properties for rules that belong to the query definition, and document the intended result when you combine them.

Set and replace runtime filters

SetRange is useful for a bounded range, such as posting dates. SetFilter supports a filter expression. Both methods target a column or filter row defined in the query. A runtime filter on the same field replaces its ColumnFilter; it intersects with the DataItemTableFilter on that field. In effect, the rows must satisfy both the static data-item condition and the runtime condition.

Set filters before you call Open. Calling SetFilter or SetRange on an open query closes that execution. Filters remain on the query instance until you clear them or replace them, so don't reuse an instance as if a previous caller's filters disappeared automatically. Use Clear when you need to reset the instance.

For method details, see Filtering in Query objects, SetFilter method, and SetRange method.