Intersoft.Client.Data.ComponentModel Namespace > QueryDescriptor Class : SortDescriptors Property |
Public Property SortDescriptors As SortDescriptorCollection
Dim instance As QueryDescriptor Dim value As SortDescriptorCollection instance.SortDescriptors = value value = instance.SortDescriptors
public SortDescriptorCollection SortDescriptors {get; set;}
public: property SortDescriptorCollection^ SortDescriptors { SortDescriptorCollection^ get(); void set ( SortDescriptorCollection^ value); }
The following example shows how to instantiate a QueryDescriptor programmatically and demonstrate the use of FilterDescriptors, SortDescriptors and PageDescriptors in the QueryDescriptor object.
CS |
Copy Code
|
---|---|
QueryDescriptor queryDescriptor = new QueryDescriptor(); // filtering // get records that have // (UnitPrice >= 0 AND UnitPrice < 50) OR (UnitPrice == 0) CompositeFilterDescriptorCollection groupFilter1 = new CompositeFilterDescriptorCollection(); groupFilter1.LogicalOperator = FilterCompositionLogicalOperator.And; groupFilter1.Add( new FilterDescriptor() { PropertyName = "UnitPrice", Operator = FilterOperator.IsGreaterThanOrEqualTo, Value = 0 } ); groupFilter1.Add( new FilterDescriptor() { PropertyName = "UnitPrice", Operator = FilterOperator.IsLessThan, Value = 50 } ); CompositeFilterDescriptorCollection groupFilter2 = new CompositeFilterDescriptorCollection(); groupFilter2.LogicalOperator = FilterCompositionLogicalOperator.And; groupFilter2.Add( new FilterDescriptor() { PropertyName = "UnitsInStock", Operator = FilterOperator.IsEqualTo, Value = 0 } ); queryDescriptor.FilterDescriptors.LogicalOperator = FilterCompositionLogicalOperator.Or; queryDescriptor.FilterDescriptors.Add(groupFilter1); queryDescriptor.FilterDescriptors.Add(groupFilter2); // paging // get the record 6 - 10 queryDescriptor.PageDescriptor.PageSize = 5; queryDescriptor.PageDescriptor.PageIndex = 1; // sorting // sort by category ascending then by product id descending queryDescriptor.SortDescriptors.Add( new SortDescriptor() { PropertyName = "CategoryID", Direction = System.ComponentModel.ListSortDirection.Ascending } ); queryDescriptor.SortDescriptors.Add( new SortDescriptor() { PropertyName = "ProductID", Direction = System.ComponentModel.ListSortDirection.Descending } ); |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2