ArcGIS Pro 3.3 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 Table GetTable()
    Public Function GetTable() As Table

    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
    public async Task ObtainingGeodatabaseFromFeatureLayer()
    {
      IEnumerable<Layer> layers = MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
    
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        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 how many rows are currently in a Table
    //Note: call within QueuedTask.Run()
    Table table = featureLayer.GetTable();
    long count = table.GetCount();
    Get the Annotation Text Graphic
    await QueuedTask.Run(() =>
    {
        using (var table = annoLayer.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, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also