ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Geodatabase Class / GetDefinition<T> Method
The type of dataset definition.
The name of the dataset.
Example Version

GetDefinition<T> Method (Geodatabase)
Gets a specific Definition instance associated with name of type T in the geodatabase. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public T GetDefinition<T>( 
   string name
)
where T: Definition

Parameters

name
The name of the dataset.

Type Parameters

T
The type of dataset definition.

Return Value

A specific Definition instance corresponding to type T.
Exceptions
ExceptionDescription

No valid geodatabase has been opened prior to calling this operation.

-or-

The DatasetType corresponding to type T is not supported.

name is invalid (e.g., a null value or an empty string).
name does not exist or cannot be opened in the geodatabase.
A geodatabase-related exception has occurred.
Example
Obtaining Definition from Geodatabase
public async Task ObtainingDefinitionFromGeodatabase()
{
    await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        {
            // Remember that for Enterprise databases you have to qualify your dataset names with the DatabaseName and UserName.
            TableDefinition enterpriseTableDefinition = geodatabase.GetDefinition<TableDefinition>("LocalGovernment.GDB.CitizenContactInfo");

            // It does not matter if the dataset is within a FeatureDataset or not.
            FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>("LocalGovernment.GDB.FireStation");

            // GetDefinition For a RelationshipClass.
            RelationshipClassDefinition relationshipClassDefinition = geodatabase.GetDefinition<RelationshipClassDefinition>("LocalGovernment.GDB.AddressPointHasSiteAddresses");

            // GetDefinition For a FeatureDataset.
            FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>("LocalGovernment.GDB.Address");
        }
    });
}
Checking for the existence of a Table
// Must be called within QueuedTask.Run9)
public bool TableExists(Geodatabase geodatabase, string tableName)
{
    try
    {
        TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableName);
        tableDefinition.Dispose();
        return true;
    }
    catch
    {
        // GetDefinition throws an exception if the definition doesn't exist
        return false;
    }
}
Checking for the existence of a Feature Class
// Must be called within QueuedTask.Run()
public bool FeatureClassExists(Geodatabase geodatabase, string featureClassName)
{
    try
    {
        FeatureClassDefinition featureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
        featureClassDefinition.Dispose();
        return true;
    }
    catch
    {
        // GetDefinition throws an exception if the definition doesn't exist
        return false;
    }
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also