ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / BasicFeatureLayer Class / GetTable Method
Example

In This Topic
    GetTable Method (BasicFeatureLayer)
    In This Topic
    Returns the underlying feature class as Table type. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetTable() As Table
    public Table GetTable()

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks

    You may want to cast it to FeatureClass.

    To ensure maximum robustness, callers should explicitly dispose of the returned ArcGIS.Core.Data.Table in either a using statement or a finally block.

    Example
    Obtaining Geodatabase from FeatureLayer
    {
      await QueuedTask.Run(() =>
      {
        IEnumerable<Layer> layers =
          MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
    
        foreach (FeatureLayer featureLayer in layers)
        {
          using (Table table = featureLayer.GetTable())
          using (Datastore datastore = table.GetDatastore())
          {
            if (datastore is UnknownDatastore)
              continue;
    
            Geodatabase geodatabase = datastore as Geodatabase;
          }
        }
      });
    }
    Gets the count of a Table or FeatureClass
    {
      //Must be called within QueuedTask.Run()
      void GetCount(FeatureLayer featureLayer)
      {
        // Row count in a Table
        Table table = featureLayer.GetTable();
        long count = table.GetCount();
    
        // Feature count in a FeatureClass
        FeatureLayer lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
        FeatureClass featureClass = lyr.GetFeatureClass();
        count = featureClass.GetCount();
      }
    }
    Get the Annotation Text Graphic
    {
    
      // Note: QueuedTask is required to access the AnnotationFeature
      {
        using var table = annotationLayer.GetTable();
        using var rc = table.Search();
        rc.MoveNext();
        using var af = rc.Current as AnnotationFeature;
        var graphic = af.GetGraphic();
        var textGraphic = graphic as CIMTextGraphic;
    
        //Note: 
        //var outline_geom = af.GetGraphicOutline(); 
        //gets the anno text outline geometry...
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also