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.
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.
}
}
});
}
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.