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
#Remarks
You can apply a DataSourceCriteriaPropertyAttribute
to a reference, collection, or enumeration property of a business class.
- For reference and collection properties, the attribute specifies the CriteriaOperator that filters the lookup list view and the list view invoked by the LinkUnlinkController.LinkAction action.
- For enumeration properties, the attribute specifies the CriteriaOperator that filters enumeration values in the combo box.
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>.