The MapDotNet UX query model is used to represent queries against spatial data sources. It has classes that encapsulate spatial queries and the resulting data sets. Typically the query model is used to create queries against map layers. Queries can also be constructed to query data tables that are not represented by map layers but this is a less common scenario.
The query model uses classes in ISC.MapDotNetServer.Common and ISC.MapDotNetServer.Common.Data. Note that the contents of these namespaces are slightly different under Silverlight. These differences will be discussed where applicable.
The QueryRequest class is used to encapsulate queries. A QueryRequest is serialized and passed to the feature service, FeatureService.svc. In the RIM controls, the Services class can be used to create a client proxy for the feature service. Otherwise, you can create one from a service reference.
The QueryRequest can contain queries against multiple map layers or other data sources. These queries may have optional attribute filters, but any spatial filter is at the level of the QueryRequest and applies to all contained Query objects.
Properties of the QueryRequest class include:
The Query class encapsulates a single data source to query within a QueryRequest object that may encompass a number of data sources.
Properties of the Query class include:
IndexHintOverride - this is used to specify a specific index to use. Only the index name is needed. Currently this is only supported for Sql Server 2008 and ignored for other providers (PostGIS does not support index hints.) There are only a few cases where it is recommended that you use this.
A service call to the Query method returns a serialized QueryResponse.
The QueryResponse class has the following properties:
The QueryResultTable class encapsulates the data returned for a single Query object.
The QueryResultTable class has the following properties:
The GetDataTable() method can be called to get an ADO.Net DataTable containing the query data. When HasTypes is true, the table columns will be typed. A column called "Geometry" will be added with serialized shapes, if available. This method is not available under Silverlight.
The QueryResultRow class contains a single row of data retrieved by a query.
TheQueryResultRow class has the following properties:
The following methods are used to query.
public string BeginQuery(string queryRequest, Guid cancelWorkKey);
Returns a serialized QueryResponse containing the requested data. queryRequest is a serialized QueryRequest. The server implementation is asynchronous. If you use an asynchronous client method, you can provide a Guid as the cancelWorkKey and the Guid can be used as an argument to CancelQuery. Make sure you use a different Guid in each call to BeginQuery. If you are not using asynchronous client processing you can pass Guid.Empty as the cancelWorkKey.
void CancelQuery(Guid cancelWorkKey);
Call this to cancel a pending query when using asynchronous client methods. Your BeginQuery callback handler will still be called but if the cancel request was received before the queries were completed, the Canceled flag will be set on the query response. If a cancel request is received after a query request is complete it is ignored.
For more on asynchronous client methods, see http://msdn.microsoft.com/en-us/library/ms228972.aspx