ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data Namespace / VersionManager Class / GetCurrentHistoricalVersion Method
Example

In This Topic
    GetCurrentHistoricalVersion Method
    In This Topic
    Gets the currently active HistoricalVersion. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetCurrentHistoricalVersion() As HistoricalVersion
    public HistoricalVersion GetCurrentHistoricalVersion()

    Return Value

    The currently active HistoricalVersion.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred.
    This method or property must be called within the lambda passed to QueuedTask.Run
    Example
    Switching between versions
    {
      // Must be called within QueuedTask.Run
      void ChangeVersions(Geodatabase geodatabase, string toVersionName)
      {
        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
            MapView.Active.Map.ChangeVersion(fromVersion, toVersion);
          }
    
          if (versionBaseType == VersionBaseType.HistoricalVersion)
          {
            HistoricalVersion fromHistoricalVersion = versionManager.GetCurrentHistoricalVersion();
            HistoricalVersion toHistoricalVersion = versionManager.GetHistoricalVersion(toVersionName);
    
            // Switch between historical versions
            MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toHistoricalVersion);
          }
    
          // Switch from HistoricalVersion to Version and vice-versa 
          // MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toVersion);
          // MapView.Active.Map.ChangeVersion(fromVersion, toHistoricalVersion);
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also