Intersoft ClientUI Documentation
QueryDescriptor Class
Members 



Object Model
QueryDescriptor ClassCompositeFilterDescriptorCollection ClassIFilterDescriptor InterfacePageDescriptor ClassSortDescriptorCollection ClassSortDescriptor Class
Syntax
Public Class QueryDescriptor 
Dim instance As QueryDescriptor
public class QueryDescriptor 
public ref class QueryDescriptor 
Remarks

QueryDescriptor is an intermediary object that contains the query information which you can use to process the query to a service for data retrieval. The query information is stored in three different properties as shown in the following figure.

As you can see in the above figure, there are three properties which contain specific query information.

QueryDescriptor provides a QueryChanged event that will be raised when any of the descriptor properties change. The QueryChanged event serves as a centralized pipeline where you want to handle all the query changes due to the actions in data controls.

CS
Copy Code
        public QueryDescriptor QueryDescriptor
        {
            get
            {
                return this._queryDescriptor;
            }
            set
            {
                if (this._queryDescriptor != value)
                {
                    if (this._queryDescriptor != null)
                        this._queryDescriptor.QueryChanged -= new System.EventHandler(OnQueryChanged);

                    this._queryDescriptor = value;
                    this._queryDescriptor.QueryChanged += new System.EventHandler(OnQueryChanged);

                    this.OnPropertyChanged("QueryDescriptor");
                }
            }
        }

        private void OnQueryChanged(object sender, System.EventArgs e)
        {
            // do data operation
        }
The QueryDescriptor concept is specifically designed for MVVM pattern implementation which allows you to bind the QueryDescriptor to your ViewModel. You can listen to its QueryChanged event and handle the data operation based on the information stored in the QueryDescriptor.
Example

The following example shows how to instantiate a QueryDescriptor programmatically and demonstrate the use of FilterDescriptor, SortDescriptor and PageDescriptor 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
    }
);    
Inheritance Hierarchy

System.Object
   Intersoft.Client.Data.ComponentModel.QueryDescriptor

Requirements

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

See Also

Reference

QueryDescriptor Members
Intersoft.Client.Data.ComponentModel Namespace

Send Feedback