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

SetObjectIDFields Method
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
)

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, Windows 8.1

ArcGIS Pro version: 2.0 or higher.
See Also