Skip to main content
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataSourceCriteriaPropertyAttribute Class

Applied to business classesreference and collection properties. Specifies the name of a CriteriaOperator type property which returns data source’s filter criteria applied to the List View displayed in a Lookup Property Editor or invoked by the LinkUnlinkController.LinkAction Action in a popup window.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v24.2.dll

NuGet Package: DevExpress.ExpressApp

#Declaration

[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
public sealed class DataSourceCriteriaPropertyAttribute :
    ModelExportedValueAttribute

#Remarks

You can filter the data source for the List View displayed in a Lookup Property Editor or in the LinkUnlinkController.LinkAction Action’s popup window. For this purpose, apply the DataSourceCriteriaProperty attribute to the target property. The constructor of this attribute accepts a string name of the CriteriaOperator type property whose value can be calculated in code as required (see DataSourceCriteriaPropertyAttribute.DataSourceCriteriaProperty).

The following example demonstrates how to use the DataSourceCriteriaProperty attribute:

using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
using System.ComponentModel.DataAnnotations;
// ...
[DefaultClassOptions]
public class Order : BaseObject {
    [DataSourceCriteriaProperty(nameof(DepartmentsCriteria))]
    public virtual Accessory Accessory { get; set; }
    public CriteriaOperator DepartmentsCriteria {
        get { return CriteriaOperator.Parse("IsGlobal = true"); }
    }
}

public class Accessory : BaseObject {
    public virtual bool IsGlobal { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

DataSourceCriteriaPropertyAttribute overrides DataSourceCriteriaAttribute when both attributes are applied to the same property.

Alternatively, you can use the IModelMember.DataSourceCriteriaProperty and IModelMemberViewItem.DataSourceCriteriaProperty settings that are available in the Application Model for the class members, ListView columns and DetailView items.

#Inheritance

Object
Attribute
DevExpress.Persistent.Base.ModelExportedValueAttribute
DataSourceCriteriaPropertyAttribute
See Also