Skip to main content
.NET 8.0+

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 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

Specifies the CriteriaOperator used to filter source data for a reference, collection, or enumeration property.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v25.1.dll

NuGet Package: DevExpress.ExpressApp

#Declaration

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

#Remarks

You can apply a DataSourceCriteriaPropertyAttribute to a reference, collection, or enumeration property of a business class.

Use DataSourceCriteriaPropertyAttribute.DataSourceCriteriaProperty to specify the name of a property that contains the CriteriaOperator.

using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
// ...
[DefaultClassOptions]
public class Order : BaseObject {
    [DataSourceCriteriaProperty(nameof(AccessoryCriteria))]
    public virtual Accessory Accessory { get; set; }
    public CriteriaOperator AccessoryCriteria {
        get { return CriteriaOperator.FromLambda<Accessory>(a => a.IsGlobal == true); }
    }
    //For enum properties
    [DataSourceCriteriaProperty(nameof(PendingConfirmedAndProcessingCriteria))]
    public virtual OrderStatus Status { get; set; }

    public CriteriaOperator PendingConfirmedAndProcessingCriteria
        => CriteriaOperator.FromLambda(o => o.Status==OrderStatus.Pending || o.Status==OrderStatus.Confirmed|| o.Status==OrderStatus.Processing);
public class Accessory : BaseObject {
    public virtual bool IsGlobal { get; set; }
}
public enum OrderStatus {
    Pending,
    Confirmed,
    Processing,
    Shipped,
    Delivered,
    Canceled,
    Returned
}

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

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

#Application Model

DataSourceCriteriaProperty property value is assigned to the corresponding property of the Application Model. You can specify the property value directly in the Model Editor at the following path: BOModel | <Class> | OwnMembers | <Member>.

#Inheritance

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