Gets a value indicating whether the ServiceChildLayer can be queried via the Query method.

Namespace:  ESRI.ArcGISExplorer.Mapping

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public bool CanQuery { get; }
Visual Basic (Declaration)
Public ReadOnly Property CanQuery As Boolean

Field Value

trueTruetruetrue (True in Visual Basic) if ServiceChildLayer supports queries; otherwise, falseFalsefalsefalse (False in Visual Basic).

Remarks

The CanQuery property of a ServiceChidLayer should always be determined prior to accessing the other query-related members on this class: QueryFeatureLimit; QueryFeature Count; and Query. If CanQuery returns false the other query-related members will throw an ExplorerException.

Version Information: This member is supported from version 2.0.0.1500.

Examples

The code below demonstrates the process of connecting to a ServiceLayer and confirming that both the top level ServiceLayer and a specific ServiceChildLayer will support queries before then accessing the Columns, QueryFeatureLimit, and QueryFeatureCount members to ensure a valid query is executed against the ServiceChildLayer via the Query method. Finally, the example connects to the FeatureLayer datasource and gets the number of rows in the result FeatureLayer table.
CopyC#
{

  //Create a new ServiceConnectionProperties instance and populate with connection information
  ServiceConnectionProperties serviceConnProps = new ServiceConnectionProperties(ServiceType.MapServer,
      new Uri("http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics"),
      "/ESRI_Census_USA");

  //Create a new ServiceLayer instance passing in the ServiceConnectionProperties 
  ServiceLayer serviceLayer = new ServiceLayer(serviceConnProps);

  //Check the ServiceLayer can Connect
  if (!serviceLayer.Connect())
    return;

  //Check this ServiceLayer supports queries
  if (!serviceLayer.CanQuery)
    return;

  //Get the "states" ServiceChildLayer on which we want to execute a query
  ServiceChildLayer serviceChildLayerStates = serviceLayer.FindByName("states") as ServiceChildLayer;

  //Check this ServiceChildlayer supports queries
  if (!serviceChildLayerStates.CanQuery)
    return;

  //Get the collection of columns for the ServiceChildLayer
  ColumnCollection columns = serviceChildLayerStates.Columns;

  //Create the WHERE clause
  string whereClause = string.Empty;

  //Check each column until the alias matches the intended query field
  foreach (Column column in columns)
  {
    //Use column members to confirm the the AliasName and data type
    if (column.AliasName == "POP2007" & column.Type == ColumnType.Integer)
    {
      //Populate the WHERE clause with matched column name, operator and value
      whereClause = column.Name + " > 10000000";
      break;
    }
  }

  //Check the WHERE clause
  if (whereClause == string.Empty)
    return;

  //Get the maximum number of records returnable from the service
  int queryFeatureLimit = serviceChildLayerStates.QueryFeatureLimit;

  //Get the number of features matching the WHERE clause
  int queryFeatureCount = serviceChildLayerStates.QueryFeatureCount(whereClause);

  //IMPORTANT: Check the feature count is not greater than the feature limit
  if (!(queryFeatureCount <= queryFeatureLimit))
    return;

  //Execute the Query method to get a new FeatureLayer containing the results
  FeatureLayer featureLayer = serviceChildLayerStates.Query(whereClause);

  //The FeatureLayer method must be called to access all FeatureLayer members
  if (!featureLayer.Connect())
    return;

  //Implement code to work with FeatureLayer (in this case get the number of rows)
  int numberOfResultFeatures = featureLayer.Table.GetRows().Count;

}
CopyVB.NET
'Create a new ServiceConnectionProperties instance and populate with connection information
Dim serviceConnProps As New ServiceConnectionProperties( _
ServiceType.MapServer, _
New Uri("http://sampleserver1.arcgisonline.com/ArcGIS/services/Demographics"), _
"/ESRI_Census_USA")

'Create a new ServiceLayer instance passing in the ServiceConnectionProperties 
Dim serviceLayer1 As New ServiceLayer(serviceConnProps)

'Check the ServiceLayer can Connect
If Not serviceLayer1.Connect() Then
  Return
End If

'Check this ServiceLayer supports queries  
If Not serviceLayer1.CanQuery Then
  Return
End If

'Get the "states" ServiceChildLayer on which we want to execute a query  
Dim serviceChildLayerStates As ServiceChildLayer = TryCast(serviceLayer1.FindByName("states"), ServiceChildLayer)

'Check this ServiceChildlayer supports queries  
If Not serviceChildLayerStates.CanQuery Then
  Return
End If

'Get the collection of columns for the ServiceChildLayer  
Dim columns As ColumnCollection = serviceChildLayerStates.Columns

'Create the WHERE clause  
Dim whereClause As String = String.Empty

'Check each column until the alias matches the intended query field  
For Each column As Column In columns

  'Use column members to confirm the the AliasName and data type  
  If column.AliasName = "POP2007" And column.Type = ColumnType.[Integer] Then

    'Populate the WHERE clause with matched column name, operator and value  
    whereClause = column.Name + " > 10000000"
    Exit For

  End If

Next

'Check the WHERE clause  
If whereClause = String.Empty Then
  Return
End If

'Get the maximum number of records returnable from the service  
Dim queryFeatureLimit As Integer = serviceChildLayerStates.QueryFeatureLimit

'Get the number of features matching the WHERE clause  
Dim queryFeatureCount As Integer = serviceChildLayerStates.QueryFeatureCount(whereClause)

'IMPORTANT: Check the feature count is not greater than the feature limit  
If Not (queryFeatureCount <= queryFeatureLimit) Then
  Return
End If

'Execute the Query method to get a new FeatureLayer containing the results  
Dim featureLayer As FeatureLayer = serviceChildLayerStates.Query(whereClause)

'The FeatureLayer method must be called to access all FeatureLayer members  
If Not featureLayer.Connect() Then
  Return
End If

'Implement code to work with FeatureLayer (in this case get the number of rows)  
Dim numberOfResultFeatures As Integer = featureLayer.Table.GetRows().Count

See Also