MessageQuery Class
Defines the core behavior of classes used to search for specific correlating data in a message.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
The MessageQuery type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CreateMessageQueryCollection | Creates a collection of queries that returns a specific type of data associated with it. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Evaluate<TResult>(Message) | When overridden in a derived class, runs a query against the message and returns a result. The body cannot be queried. |
![]() | Evaluate<TResult>(MessageBuffer) | When overridden in a derived class, runs a query against the message and returns a result. |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The MessageQuery class is similar to the MessageFilter class. However, instead of returning matches, the Evaluate() method returns the results of evaluating a query against a message. The result of the query is a value in the message. Use the value as a key to correlate the message to other messages. To add a new property for the data, use the Add(String, Func<String>) method of the CorrelationDataMessageProperty class.
Note |
|---|
For a concrete implementation of the MessageQuery, see the XPathMessageQuery class. |
Using the XPathMessageQuery and MessageQueryCollection classes
You can optimize the query process by creating a set of query objects and inserting them into an instance of the MessageQueryCollection class.
Note |
|---|
For a concrete implementation of the MessageQueryCollection, see the XPathMessageQueryCollection class. |
A common usage is to populate the collection with queries that have the same XPath predicate, but that differ only in the final leaf value. For example, the following XPath queries are identical except for the final clause. The first queries for all elements that have the quantity attribute set to 1, and the second queries for elements with the product attribute set to 'Contoso'):
"/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 1]" "/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@product = 'Contoso']"
The MessageQueryCollection class allows you to create tables of queries that differ only slightly, enabling more efficient processing.
Alternatively, you can use the MessageQueryTable<TItem> class to store and evaluate message queries.
The following example creates a message and XPath message queries. The queries are evaluated by the XPathMessageQuery objects contained in an XPathMessageQueryCollection object. The results of each query are tested using the ResultType property of the XPathResult class.
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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
