ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Selection Class
Members Example Version

Selection Class
Represents a selection of rows based on IDs or global IDs from a geodatabase table.
Object Model
Selection ClassSelection ClassRowCursor ClassSelection Class
Syntax
public sealed class Selection : ArcGIS.Core.CoreObjectsBase, System.IDisposable  
Example
Selecting Rows from a Table
public async Task SelectingRowsFromATable()
{
    await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        using (Table enterpriseTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.piCIPCost"))
        {
            QueryFilter anotherQueryFilter = new QueryFilter { WhereClause = "FLOOR = 1 AND WING = 'E'" };

            // For Selecting all matching entries.
            using (Selection anotherSelection = enterpriseTable.Select(anotherQueryFilter, SelectionType.ObjectID, SelectionOption.Normal))
            {
            }

            // This can be used to get one record which matches the criteria. No assumptions can be made about which record satisfying the criteria is selected.
            using (Selection onlyOneSelection = enterpriseTable.Select(anotherQueryFilter, SelectionType.ObjectID, SelectionOption.OnlyOne))
            {
            }

            // This can be used to obtain a empty selction which can be used as a container to combine results from different selections.
            using (Selection emptySelection = enterpriseTable.Select(anotherQueryFilter, SelectionType.ObjectID, SelectionOption.Empty))
            {
            }

            // If you want to select all the records in a table.
            using (Selection allRecordSelection = enterpriseTable.Select(null, SelectionType.ObjectID, SelectionOption.Normal))
            {
            }
        }
    });
}
Inheritance Hierarchy

System.Object
   ArcGIS.Core.CoreObjectsBase
      ArcGIS.Core.Data.Selection

Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also