ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core Namespace / EditingOptions Class / IsSingleWorkspaceEditSession Property
Example

In This Topic
    IsSingleWorkspaceEditSession Property
    In This Topic
    Gets and sets whether only data from a single workspace can be edited within an edit session. Specify the workspace to be edited using the
    Syntax
    Public Property IsSingleWorkspaceEditSession As Boolean
    public bool IsSingleWorkspaceEditSession {get; set;}
    Remarks
    If this option is false, then data from multiple workspaces can be edited within an edit session. The edit session is automatically started by the application.
    Example
    Start a Single workspace edit session via a MapMember
    {
      // ApplicationOptions.EditingOptions.EnableEditingFromEditTab is true
      // ApplicationOptions.EditingOptions.IsSingleWorkspaceEditSession is true
    
      // find a layer
      var mm = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == "Roads");
      if (mm == null)
        return;
    
      var project = Project.Current;
      var success = await project.SetSingleEditWorkspaceAsync(mm);
    
      // if success = true then an edit session was started
      // and project.IsEditingEnabled will be true
    }
    Start a single workspace edit session - Full example
    {
      // ApplicationOptions.EditingOptions.EnableEditingFromEditTab is true
      // ApplicationOptions.EditingOptions.IsSingleWorkspaceEditSession is true
    
      var project = Project.Current;
    
      // check if already editing
      if (project.IsEditingEnabled)
      {
        // save or discard any edits
        if (project.HasEdits)
        {
          var res = MessageBox.Show("Save edits?", "Save Edits?", System.Windows.MessageBoxButton.YesNoCancel);
          if (res == System.Windows.MessageBoxResult.Cancel)
            return;
          else if (res == System.Windows.MessageBoxResult.No)
            await project.DiscardEditsAsync();
          else
            await project.SaveEditsAsync();
        }
        // close the edit session
        await project.SetIsEditingEnabledAsync(false);
      }
    
      // find a layer
      var mm = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == "Roads");
      if (mm == null)
        return;
    
      // start the edit session on the workspace attached to the layer
      var success = await project.SetSingleEditWorkspaceAsync(mm);
    
      // if success = true then an edit session was started
      // and project.IsEditingEnabled will be true
    }
    Start a Single workspace edit session via a DatastoreConfiguration
    {
      // ApplicationOptions.EditingOptions.EnableEditingFromEditTab is true
      // ApplicationOptions.EditingOptions.IsSingleWorkspaceEditSession is true
    
      Geodatabase egdb = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")));
    
      // setup the configuration to edit the data registered as versioned in the egdb
      var datastoreConfig = new DatastoreConfiguration(egdb, VersionState.Versioned);
    
      // start the edit session on the workspace
      var project = Project.Current;
      var v_success = await project.SetSingleEditWorkspaceAsync(datastoreConfig);
    
      // OR 
    
      // setup the configuration to edit the data that is not registered as versioned
      var nonVersionedDatastoreConfig = new DatastoreConfiguration(egdb, VersionState.NonVersioned);
      // start the edit session on the workspace
      var nv_success = await project.SetSingleEditWorkspaceAsync(nonVersionedDatastoreConfig);
    }
    Requirements

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

    ArcGIS Pro version: 3.6 or higher.
    See Also