ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data Namespace / Geodatabase Class / GetDefinitions<T> Method
The type of dataset definition.
Example

In This Topic
    GetDefinitions<T> Method (Geodatabase)
    In This Topic
    Gets an IReadOnlyList of specific Definition instances associated with each dataset of type T in the geodatabase. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public IReadOnlyList<T> GetDefinitions<T>()
    where T: Definition
    Public Function GetDefinitions(Of T As Definition)() As IReadOnlyList(Of T)

    Type Parameters

    T
    The type of dataset definition.

    Return Value

    A IReadOnlyList of specific Definition instances corresponding to type T.
    Exceptions
    ExceptionDescription
    No valid geodatabase has been opened prior to calling this operation or the DatasetType type is not supported.
    A geodatabase-related exception has occurred.
    Remarks
    Asking for TableDefinition will only return definitions for non-spatial tables (not feature classes), but asking for FeatureClassDefinition will return regular feature classes, as well as annotation and dimensioning feature classes.
    Example
    Obtaining List of Defintions from Geodatabase
    public async Task ObtainingDefinitionsFromGeodatabase()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        {
          IReadOnlyList<FeatureClassDefinition> enterpriseDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
          IEnumerable<Definition> featureClassesHavingGlobalID = enterpriseDefinitions.Where(definition => definition.HasGlobalID());
    
          IReadOnlyList<FeatureDatasetDefinition> featureDatasetDefinitions = geodatabase.GetDefinitions<FeatureDatasetDefinition>();
          bool electionRelatedFeatureDatasets = featureDatasetDefinitions.Any(definition => definition.GetName().Contains("Election"));
    
          IReadOnlyList<AttributedRelationshipClassDefinition> attributedRelationshipClassDefinitions = geodatabase.GetDefinitions<AttributedRelationshipClassDefinition>();
    
          IReadOnlyList<RelationshipClassDefinition> relationshipClassDefinitions = geodatabase.GetDefinitions<RelationshipClassDefinition>();
        }
      });
    }
    Obtaining related Feature Classes from a Relationship Class
    public async Task GetFeatureClassesInRelationshipClassAsync()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb"))))
        {
          IReadOnlyList<RelationshipClassDefinition> relationshipClassDefinitions = geodatabase.GetDefinitions<RelationshipClassDefinition>();
    
          foreach (RelationshipClassDefinition relationshipClassDefinition in relationshipClassDefinitions)
          {
            IReadOnlyList<Definition> definitions = geodatabase.GetRelatedDefinitions(relationshipClassDefinition, DefinitionRelationshipType.DatasetsRelatedThrough);
    
            foreach (Definition definition in definitions)
            {
              System.Diagnostics.Debug.WriteLine($"Feature class in the RelationshipClass is:{definition.GetName()}");
            }
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also