ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data Namespace / QueryFilter Class / ObjectIDs Property
Example

In This Topic
    ObjectIDs Property
    In This Topic
    Gets or sets the list of objectIDs used for filtering data in the underlying data store.
    Syntax
    Public Property ObjectIDs As IReadOnlyList(Of Long)
    public IReadOnlyList<long> ObjectIDs {get; set;}
    Remarks
    If ObjectIDs inputs are used in conjunction with WhereClause and/or SpatialQueryFilter.FilterGeometry, the resulting rows/features will be those whose objectIDs intersect with the inputs in ObjectIDs and objectsIDs corresponding to the input WhereClause and/or FilterGeometry.
    Example
    QueryFilter queryFilter = new QueryFilter()
    {
      ObjectIDs = new List<long>() { 1, 2, 3, 5, 6, 8 },
      WhereClause = "OWNER_NAME = 'John Smith'" // The OID of 'John Smith' is 6.
    };
                 
    using (RowCursor rowCursor = table.Search(queryFilter, false))
    {
      List<Row> actualRows = new List<Row>();
                
      try
      {
         while (rowCursor.MoveNext())
         {
           actualRows.Add(rowCursor.Current);
         }
                 
         Assert.AreEqual(1, actualRows.Count, "There is only 1 OID (6) in ObjectsIDs that intersects with the result from the where clause.");
         Assert.AreEqual(6, actualRows[0].GetObjectID(), "The intersecting OID corresponding to 'John Smith' should be 6.");
      }
      finally
      {
        foreach (Row row in actualRows)
          row.Dispose();
      }
    }
    Searching a Table using a set of ObjectIDs
    {
      //Must be called within QueuedTask.Run()
      RowCursor SearchingATable(Table table, IReadOnlyList<long> objectIDs)
      {
        QueryFilter queryFilter = new QueryFilter()
        {
          ObjectIDs = objectIDs
        };
    
        return table.Search(queryFilter);
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also