ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data Namespace / QueryFilter Class / PostfixClause Property
Example

In This Topic
    PostfixClause Property (QueryFilter)
    In This Topic
    Gets or sets the postfix clause used by the filter.
    Syntax
    public string PostfixClause {get; set;}
    Public Property PostfixClause As String
    Remarks
    A clause that will be appended to the SELECT statement, following the where clause. Most commonly used for clauses like ORDER BY. e.g., SELECT ArcGIS.Core.Data.QueryFilter.PrefixClauseP:ArcGIS.Core.Data.QueryFilter.PostfixClause.
    Example
    Searching a Table using QueryFilter
    {
      await QueuedTask.Run(() =>
      {
        try
        {
          using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
          using (Table table = geodatabase.OpenDataset<Table>("EmployeeInfo"))
          {
            QueryFilter queryFilter = new QueryFilter
            {
              WhereClause = "COSTCTRN = 'Information Technology'",
              SubFields = "KNOWNAS, OFFICE, LOCATION",
              PostfixClause = "ORDER BY OFFICE"
            };
    
            using (RowCursor rowCursor = table.Search(queryFilter, false))
            {
              while (rowCursor.MoveNext())
              {
                using (Row row = rowCursor.Current)
                {
                  string location = Convert.ToString(row["LOCATION"]);
                  string knownAs = Convert.ToString(row["KNOWNAS"]);
                }
              }
            }
          }
        }
        catch (GeodatabaseFieldException fieldException)
        {
          // One of the fields in the where clause might not exist. There are multiple ways this can be handled:
          // Handle error appropriately
        }
      });
    }
    Fulltext search query
    {
      await QueuedTask.Run(() =>
      {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        using (Table table = geodatabase.OpenDataset<Table>("WaterPipeInfo"))
        using (TableDefinition tableDefinition = table.GetDefinition())
        {
          bool supportsFullText = geodatabase.GetDatastoreProperties().SupportsFullTextIndex;
          if (!supportsFullText)
          {
            return;
          }
    
          IReadOnlyList<Index> indexes = tableDefinition.GetIndexes();
          IReadOnlyList<Field> fieldsToSearch = indexes.First().GetFields();
    
          FullTextSearchTermExpression searchRepairStatus = new FullTextSearchTermExpression()
          {
            SearchFields = fieldsToSearch[0].Name,
            SearchTerm = "Repaired",
            SearchType = FullTextSearchType.Simple
          };
    
          FullTextSearchTermExpression searchPipeMaterial = new FullTextSearchTermExpression()
          {
            SearchFields = fieldsToSearch[1].Name,
            SearchTerm = "Copper",
            SearchType = FullTextSearchType.Simple
          };
    
          FullTextOrExpression repairedOrCopperEx = new FullTextOrExpression(searchRepairStatus, searchPipeMaterial);
    
          QueryFilter queryfilter = new QueryFilter
          {
            FullTextExpression = repairedOrCopperEx,
            Offset = 1,
            RowCount = 20,
            PostfixClause = "Order By Size"
          };
    
          using (RowCursor rowCursor = table.Search(queryfilter, false))
          {
            // Use row cursor ...
          }
        }
      });
    }
    Pagination in QueryFilter
    {
      Task QueryFilterWithPaginationAsync(Table table, List<long> objectIDs) => QueuedTask.Run(() =>
      {
        int rowsPerBatch = 100;
        int offset = 0;
    
        // Query filter
        // Some datastores support pagination only through an SQL postfix clause
        QueryFilter queryFilter = new QueryFilter()
        {
          ObjectIDs = objectIDs,
          PostfixClause = "ORDER BY OBJECTID"
        };
    
        // Fetch rows in a batch from a table
        for (int index = offset; index <= objectIDs.Count; index += rowsPerBatch)
        {
          // Set number of rows to return from a table
          queryFilter.RowCount = rowsPerBatch;
    
          // Set positional offset to skip number of rows from a table
          queryFilter.Offset = index;
    
          using (RowCursor cursor = table.Search(queryFilter))
          {
            while (cursor.MoveNext())
            {
              using (Row row = cursor.Current)
              {
                Console.WriteLine(row.GetObjectID());
              }
            }
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also