Skip to main content
.NET Framework 4.6.2+

CollectionSourceBase.Criteria Property

Provides access to the Collection Source’s CriteriaOperator dictionary that define the way in which the Collection Source’s CollectionSourceBase.Collection is filtered.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public LightDictionary<string, CriteriaOperator> Criteria { get; }

Property Value

Type Description
DevExpress.ExpressApp.Utils.LightDictionary<String, CriteriaOperator>

A LightDicationary of the CriteriaOperator objects that define the way in which the Collection Source’s CollectionSourceBase.Collection is filtered.

Remarks

To filter a Collection Source’s collection, add the required CriteriaOperators to the Criteria dictionary. No additional methods have to be called. The dictionary holds <String, CriteriaOperator> pairs. The String contains the description of a criterion and the CriteriaOperator denotes the criterion. The LightDictionary class implements the IDictionary interface. So, you can use its methods and properties - Add, Clear, Count, Remove and others.

When the content of the Criteria dictionary is changed, the Collection Source’s collection is filtered automatically. Two events are executed in the process - the CollectionSourceBase.CriteriaApplying and CollectionSourceBase.CriteriaApplied. Handle them to receive notifications when the Collection Source’s collection is filtered.

A persistent object used in Collection Source’s Criteria does not reload when the Object Space is refreshed, which raises the SessionMixingException exception. To avoid this, use a persistent object’s key property instead of the object itself.

View.CollectionSource.Criteria["Filter1"] = CriteriaOperator.Parse("Manager.Oid = ?", ObjectSpace.GetKeyValue(manager));

The following topics contain examples on accessing and manipulating the Criteria dictionary:

Note

  • In nested List Views, the Criteria is not directly applied to the associated collection. Instead, a separate collection is created, and the criteria are applied to it; the original associated collection is not modified. A nested List View in the Client data access mode with a disabled proxy collection (see XafApplication.DefaultCollectionSourceMode) is an exception. In this instance, the criteria are directly applied to the associated collection.

  • Currently, TreeListEditor has limited filtering capabilities. Only root tree nodes are filtered if you specify the Collection Source’s Criteria property when filtering the List View.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Criteria property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also