public void ChangeVersion( Version fromVersion, Version toVersion )
Public Overloads Sub ChangeVersion( _ ByVal fromVersion As Version, _ ByVal toVersion As Version _ )
public void ChangeVersion( Version fromVersion, Version toVersion )
Public Overloads Sub ChangeVersion( _ ByVal fromVersion As Version, _ ByVal toVersion As Version _ )
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
System.InvalidOperationException | This operation is not supported on a map with pending edits. |
await QueuedTask.Run(() => { //Getting the current version name from the first feature layer of the map FeatureLayer flyr = MapView.Active.Map.GetLayersAsFlattenedList() .OfType<FeatureLayer>().FirstOrDefault(); //first feature layer Datastore dataStore = flyr.GetFeatureClass().GetDatastore(); //getting datasource Geodatabase geodatabase = dataStore as Geodatabase; //casting to Geodatabase if (geodatabase == null) return; VersionManager versionManager = geodatabase.GetVersionManager(); ArcGIS.Core.Data.Version currentVersion = versionManager.GetCurrentVersion(); //Getting all available versions except the current one IEnumerable<ArcGIS.Core.Data.Version> versions = versionManager.GetVersions() .Where(v => !v.GetName().Equals(currentVersion.GetName(), StringComparison.CurrentCultureIgnoreCase)); //Assuming there is at least one other version we pick the first one from the list ArcGIS.Core.Data.Version toVersion = versions.FirstOrDefault(); if (toVersion != null) { //Changing version MapView.Active.Map.ChangeVersion(currentVersion, toVersion); } });
Target Platforms: Windows 10, Windows 8.1