ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data Namespace / Geodatabase Class / OpenQueryTable Method
Provides the details of how to create the query table.
Example

In This Topic
    OpenQueryTable Method
    In This Topic
    Opens a query table based on the queryTableDescription. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function OpenQueryTable( _
       ByVal queryTableDescription As QueryTableDescription _
    ) As Table

    Parameters

    queryTableDescription
    Provides the details of how to create the query table.

    Return Value

    A Table or FeatureClass (if it is spatially enabled) that represents the query table.
    Exceptions
    ExceptionDescription
    No valid geodatabase has been opened prior to invoking this operation.
    queryTableDescription is null.
    A geodatabase-related exception has occurred.
    Remarks
    The Table or FeatureClass returned is the representation of the QueryDef (included in the QueryTableDescription). It is primarily intended to be used for performing search, adding to the map for visualization and working with geoprocessing analysis tools. It should be noted that selections are not currently supported on the resulting table or feature class.
    Example
    Creating a QueryTable using a query which joins two versioned tables in a geodatabase
    public async Task QueryTableJoinWithVersionedData()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        QueryDef queryDef = new QueryDef
        {
          Tables = "CommunityAddress JOIN MunicipalBoundary on CommunityAddress.Municipality = MunicipalBoundary.Name",
          SubFields = "CommunityAddress.OBJECTID, CommunityAddress.Shape, CommunityAddress.SITEADDID, CommunityAddress.ADDRNUM, CommunityAddress.FULLNAME, CommunityAddress.FULLADDR, CommunityAddress.MUNICIPALITY, MunicipalBoundary.Name, MunicipalBoundary.MUNITYP, MunicipalBoundary.LOCALFIPS",
        };
    
        using (Geodatabase testVersion1Geodatabase = new Geodatabase(new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
        {
          AuthenticationMode = AuthenticationMode.DBMS,
          Instance = "instance",
          User = "user",
          Password = "password",
          Database = "database",
          Version = "user.testVersion1"
        }))
        {
          QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)
          {
            Name = "CommunityAddrJounMunicipalBoundr",
            PrimaryKeys = testVersion1Geodatabase.GetSQLSyntax().QualifyColumnName("CommunityAddress", "OBJECTID")
          };
    
          // Will be based on testVersion1.
          using (Table queryTable = testVersion1Geodatabase.OpenQueryTable(queryTableDescription))
          {
            // Use queryTable.
          }
        }
    
        using (Geodatabase testVersion2Geodatabase = new Geodatabase(new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
        {
          AuthenticationMode = AuthenticationMode.DBMS,
          Instance = "instance",
          User = "user",
          Password = "password",
          Database = "database",
          Version = "user.testVersion2"
        }))
        {
          QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)
          {
            Name = "CommunityAddrJounMunicipalBoundr",
            PrimaryKeys = testVersion2Geodatabase.GetSQLSyntax().QualifyColumnName("CommunityAddress", "OBJECTID")
          };
    
          // Will be based on testVersion2.
          using (Table queryTable = testVersion2Geodatabase.OpenQueryTable(queryTableDescription))
          {
            // Use queryTable.
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also