ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data Namespace / Selection Class / Search Method
This argument is optional. If unset or set to null, a default query filter will be used, which will cause all rows to be returned.
If set to true, all the entries in RowCursor will reference the most current row returned by Current. To ensure all the entries in RowCursor remain unique, set useRecyclingCursor to false.
Example

In This Topic
    Search Method (Selection)
    In This Topic
    Search and retrieve specific rows in this Selection that satisfy the criteria set in the queryFilter. If no query filter is set, all rows will be retrieved. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function Search( _
       Optional ByVal queryFilter As QueryFilter, _
       Optional ByVal useRecyclingCursor As Boolean _
    ) As RowCursor

    Parameters

    queryFilter
    This argument is optional. If unset or set to null, a default query filter will be used, which will cause all rows to be returned.
    useRecyclingCursor
    If set to true, all the entries in RowCursor will reference the most current row returned by Current. To ensure all the entries in RowCursor remain unique, set useRecyclingCursor to false.

    Return Value

    A RowCursor that encapsulates the retrieved rows.
    Exceptions
    ExceptionDescription
    If queryFilter is an instance of SpatialQueryFilter, either both the 'FilterGeometry' and 'SpatialRelationship' properties are set or both are not set. Otherwise, an ArgumentException will be raised.
    A geodatabase-related exception has occurred.
    Example
    Use Select or Search with a Spatial Query
    //var featSceneLayer = ...;
    //var sname = featSceneLayer.Name;
    await QueuedTask.Run(() =>
    {
      if (!featSceneLayer.HasAssociatedFeatureService)
        return;//no search or select
    
      //Select all features within the current map view
      var sz = MapView.Active.GetViewSize();
      var map_pt1 = MapView.Active.ClientToMap(new System.Windows.Point(0, sz.Height));
      var map_pt2 = MapView.Active.ClientToMap(new System.Windows.Point(sz.Width, 0));
    
      //Convert to an envelope
      var temp_env = EnvelopeBuilderEx.CreateEnvelope(map_pt1, map_pt2, MapView.Active.Map.SpatialReference);
    
      //Project if needed to the layer spatial ref
      SpatialReference sr = null;
      using (var fc = featSceneLayer.GetFeatureClass())
      using (var fdef = fc.GetDefinition())
        sr = fdef.GetSpatialReference();
    
      var env = GeometryEngine.Instance.Project(temp_env, sr) as Envelope;
    
      //Set up a query filter
      var sf = new SpatialQueryFilter()
      {
        FilterGeometry = env,
        SpatialRelationship = SpatialRelationship.Intersects,
        SubFields = "*"
      };
    
      //Select against the feature service
      var select = featSceneLayer.Select(sf);
      if (select.GetCount() > 0)
      {
        //enumerate over the selected features
        using (var rc = select.Search())
        {
          while (rc.MoveNext())
          {
            using (var feature = rc.Current as Feature)
            {
              var oid = feature.GetObjectID();
              //etc.
            }
          }
        }
      }
    
      MapView.Active.Map.ClearSelection();
    
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also