ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Catalog Namespace / GDBProjectItem Class
Members Example

In This Topic
    GDBProjectItem Class
    In This Topic
    Represents a database project item.
    Object Model
    GDBProjectItem ClassDatastore ClassItemInfoValue StructureTimeInstant Class
    Syntax
    public sealed class GDBProjectItem : ArcGIS.Desktop.Internal.Catalog.ProjectItemInfoCrawl, ArcGIS.Desktop.Core.IMetadata, ArcGIS.Desktop.Core.IProjectItem, System.ComponentModel.INotifyPropertyChanged  
    Public NotInheritable Class GDBProjectItem 
       Inherits ArcGIS.Desktop.Internal.Catalog.ProjectItemInfoCrawl
       Implements ArcGIS.Desktop.Core.IMetadata, ArcGIS.Desktop.Core.IProjectItem, System.ComponentModel.INotifyPropertyChanged 
    Remarks

    A database project item is a file geodatabase, enterprise geodatabase, SQLite database, or a geopackage that has been added to the current project.

    Example
    Add GDBProjectItem to Project as IProjectItem
    /// Add a file geodatabase or a SQLite or enterprise database connection to a project
    Item gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals("CountyData.gdb"));
    var addedGeodatabase = await QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem));
    
    Get all "GDBProjectItems"
    IEnumerable<GDBProjectItem> newGDBItemsContainer = null;
    newGDBItemsContainer = Project.Current.GetItems<GDBProjectItem>();
    foreach (var GDBItem in newGDBItemsContainer)
    {
      //Do Something with the GDB.
    }
    Get a specific "GDBProjectItem"
    GDBProjectItem GDBProjItem = Project.Current.GetItems<GDBProjectItem>().FirstOrDefault(item => item.Name.Equals("myGDB"));
    Obtaining Geodatabase from Project Item
    public async Task ObtainingGeodatabaseFromProjectItem()
    {
      IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
    
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        foreach (GDBProjectItem gdbProjectItem in gdbProjectItems)
        {
          using (Datastore datastore = gdbProjectItem.GetDatastore())
          {
            //Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore
            if (datastore is UnknownDatastore)
              continue;
    
            Geodatabase geodatabase = datastore as Geodatabase;
            // Use the geodatabase.
          }
        }
      });
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
          ArcGIS.Desktop.Core.Item
                      ArcGIS.Desktop.Catalog.GDBProjectItem

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also