ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Data Namespace / VersionManager Class / GetCurrentVersionBaseType Method
Example

In This Topic
    GetCurrentVersionBaseType Method
    In This Topic
    Gets whether the VersionManager belongs to a Geodatabase that is connected to a Version or a HistoricalVersion.
    Syntax
    public VersionBaseType GetCurrentVersionBaseType()
    Public Function GetCurrentVersionBaseType() As VersionBaseType

    Return Value

    The type of VersionBase of the current Version.
    Exceptions
    ExceptionDescription
    The current VersionBase is invalid.
    A geodatabase-related exception has occurred.
    Example
    Switching between versions
    {
      Task ChangeVersionsAsync(Geodatabase geodatabase, string toVersionName)
      {
        var map = MapView.Active?.Map;
        if (map == null)
          return Task.CompletedTask;
    
        return QueuedTask.Run(() =>
        {
          using (VersionManager versionManager = geodatabase.GetVersionManager())
          {
            VersionBaseType versionBaseType = versionManager.GetCurrentVersionBaseType();
    
            if (versionBaseType == VersionBaseType.Version)
            {
              Version fromVersion = versionManager.GetCurrentVersion();
              Version toVersion = versionManager.GetVersion(toVersionName);
    
              // Switch between versions
              map.ChangeVersion(fromVersion, toVersion);
            }
    
            if (versionBaseType == VersionBaseType.HistoricalVersion)
            {
              HistoricalVersion fromHistoricalVersion = versionManager.GetCurrentHistoricalVersion();
              HistoricalVersion toHistoricalVersion = versionManager.GetHistoricalVersion(toVersionName);
    
              // Switch between historical versions
              map.ChangeVersion(fromHistoricalVersion, toHistoricalVersion);
            }
    
            // Switch from HistoricalVersion to Version and vice-versa
            // map.ChangeVersion(fromHistoricalVersion, toVersion);
            // map.ChangeVersion(fromVersion, toHistoricalVersion);
          }
        });
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also