ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data Namespace / QueryDescription Class / SetObjectIDFields Method
A comma-separated unique key field(s).
Example

In This Topic
    SetObjectIDFields Method
    In This Topic
    Sets the unique key field(s) that fulfill the role of a table's objectID. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetObjectIDFields( 
       string objectIDFields
    )
    Public Sub SetObjectIDFields( _
       ByVal objectIDFields As String _
    ) 

    Parameters

    objectIDFields
    A comma-separated unique key field(s).
    Exceptions
    ExceptionDescription
    A database-related exception has occurred.
    Example
    Create QueryDescription from a join query where there is no non-nullable unique id column
    public async Task JoinQueryDescription()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        DatabaseConnectionProperties databaseConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
        {
          AuthenticationMode = AuthenticationMode.DBMS,
          Instance = "instance",
          Database = "database",
          User = "user",
          Password = "password"
        };
    
        using (Database database = new Database(databaseConnectionProperties))
        {
          QueryDescription queryDescription = database.GetQueryDescription("SELECT BUSLINES.ID as BUSLINESID, BUSSTOPS.ID as BUSSTOPSID, BUSLINES.RTE_DESC, BUSLINES.DIR, BUSSTOPS.JURISDIC, BUSSTOPS.LOCATION, BUSSTOPS.ROUTE,BUSSTOPS.SHAPE from demosql.dbo.BUSSTOPS JOIN demosql.dbo.BUSLINES ON BUSSTOPS.ROUTE = BUSLINES.ROUTE", "BusInfo");
    
          queryDescription.SetObjectIDFields("BUSLINESID,BUSSTOPSID");
    
          using (Table table = database.OpenTable(queryDescription))
          {
            // Use the table.
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also