Overview
Queries are handled by the
MapControlBridge.Query method and the
Common .Net SDK classes QueryRequest, Query, QuerySort, QueryResponse, QueryResultTable, and QueryResultRow classes. Queries can also be built and executed by the
MapQueryManager class, which also provides support for sophisticated result formatting.
QueryRequest Class
The QueryRequest class encapsulates one or more queries to be executed. Properties include:
- ShapeFilterSerial - if provided, this is a serialized shape that will be used as a spatial filter for all queries included in the request. (Use Shape.SerializeShape to serialize a shape.) Note that the shape should be in the same coordinate reference system as the layers to be queried.
- ShapeFilterOperation - an instance of the ShapeFilterOperations enumeration used to indicate how shapes should be filtered against ShapeFilterSerial. Most of the operations are self-explanatory. "DRILL_DOWN" applies any provided ShapeFilterBuffer to searches against point or line layers but does not apply the buffer to searches against polygon layers. "DRILL_DOWN" is designed to be used for point click or point hover searches across multiple layers.
- ShapeFilterBufferUsed - set true to apply a buffer to the filter shape. A buffer is necessary, for instance, when using a point to search point or line layers. Note that if the shape is in a geographic coordinate reference system you should not buffer it in this way. Use a TransformRequest and set the InterimBufferingProjection property appropriately prior to serializing the shape.
- ShapeFilterBufferDistance - distance to buffer the shape by.
- ReturnShapes - set true to include shape data in the query response. ArcSDE backends also require that the geometry column be included in the Fields collection of each associated query to return shapes. PostGIS backends do not have this limitation.
- MaxRows - if greater than 0, limits the number of rows returned.
- ResultShapeCoordSys - if non-null, the CoordSys to project results shapes to. The projection will be from the coordinate reference system of the layer queried.
- ResultShapeBufferUsed - set true and provide ResultShapeBufferDistance to buffer shapes returned by the query. Note that if ResultShapeCoordSys is a geographic coordinate reference system or if ResultShapeCoordSys is null and the coordinate reference system of the layer queried is geographic, then you should not buffer result shapes in this way. Instead use a TransformRequest to transform the result shapes and set the InterimBufferingProjection property appropriately.
- ResultShapeBufferDistance - distance to buffer result shapes by.
- Queries - a list of Query objects representing queries to perform within the parameters of this QueryRequest.
Query Class
The Query class represents a single query within a QueryRequest. Properties include:
- Layer - the Layer to query.
- Filter - an optional query string to filter results by attribute values.
- Fields - the list of fields in the layer that should be returned by the query.
- QuerySort - if non-null, a sort to apply to query results.
QuerySort Class
The QuerySort class indicates how to sort the results from a query. Properties include:
- Field - the field to sort on.
- Direction - indicates whether to sort ascending or descending.
- Type - indicates whether to sort as text (case-sensitive or otherwise) or as numeric or DateTime data.
QueryResponse Class
The QueryResponse class encapsulates the response to a QueryRequest. Properties include:
- Error - any overall error that prevented executing any queries.
- QueryResultTables - a list of QueryResultTable objects representing the results of the Queries in the QueryRequest.
A useful method of this class is FillDataSet, which takes a DataSet and adds a DataTable to it for each QueryResultTable in this QueryResponse (empty result tables can be optionally omitted.) Table names match the IDs of the layers queried. All data will be in the form of strings. Column names match field names, and serialized shapes are in a column called "Geometry".
QueryResultTable Class
The QueryResultTable class contains the result of a single Query within a QueryRequest. Properties include:
- Name - the ID of the Layer the query was executed against.
- Error - any error that occured executing the query.
- Fields - the fields returned by the query.
- QueryResultRows - a list of QueryResultRow objects representing the data rows returned by the query. This list may be empty if the query had no errors but also found no data.
A useful method of this class is GetDataTable, which returns a DataTable with the data from this QueryResultTable. The table name is the ID of the layer queried. All data is in the form of strings. Column names match field names, and serialized shapes are in a column called "Geometry".
QueryResultRow Class
The QueryResultRow represents a single row of data returned as part of the result of a single Query within a QueryRequest. Properties include:
- ShapeSerial - the serialized shape for this row, if included (see QueryRequest.ReturnShapes above).
- Values - a list of field values, in the same order as in the Fields list of the QueryResultTable that contains this QueryResultRow.
MapControlBridge.Query Method
This method takes a QueryRequest object, passes it to the FeatureService, and returns the resulting QueryResponse.
EditRequest Class
EditRequest encapsulates one or more edits- row inserts, updates, or deletes- to perform against a spatial layer. Properties include:
- Layer - the Layer to edit.
- Data - a DataTable containing rows to insert, update, or delete. Data is interpreted as follows:
- The RowState of each row indicates the action to perform for that row.
- Column names must correspond to layer field names.
- If the geometry is edited, a column with the name of the geometry column should contain string values that are serialized shapes.
- The PrimaryKey property of the table should be set. Updated and deleted rows will be looked up using this key. It does not have to be the actual primary key column of the layer, but if not it should still identify rows uniquely. If there are only inserted rows and not updated or deleted ones a primary key does not have to be specified but for ArcSDE backends, if it is provided it should be the actual primary key column.
- DataCoordSys - a CoordSys representing the coordinate reference system the data is in. This need only be set if there are inserts or updates and the data is not in the same coordinate system as the layer.
MapControlBridge.Edit Method
This method takes an EditRequest, passes it to the FeatureUpdateService, and returns the resulting DataTable. Rows in the DataTable correspond to rows in the Data property of the EditRequest.
If an overall error prevented any edits, the table will have an extended property (DataTable.ExtendedProperties) called "Error" detailing this. If an individual edit had an error, the RowError property of the row will be set to an error message. For ArcSDE backends, if the row was inserted and the PrimaryKey property was set on the EditRequest's Data object then that column will be set with the new primary key value for the row.