ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Desktop.Core Namespace / EditingProjectExtender Class / SetSingleEditWorkspaceAsync Method / SetSingleEditWorkspaceAsync(Project,MapMember) Method
The mapMember to edit.
Example

In This Topic
    SetSingleEditWorkspaceAsync(Project,MapMember) Method
    In This Topic
    Start a single edit workspace session using the datastore of the specified mapMember.
    Syntax
    public static Task<bool> SetSingleEditWorkspaceAsync( 
       Project project,
       MapMember mapMember
    )
    Public Overloads Shared Function SetSingleEditWorkspaceAsync( _
       ByVal project As Project, _
       ByVal mapMember As MapMember _
    ) As Task(Of Boolean)

    Parameters

    project
    mapMember
    The mapMember to edit.

    Return Value

    A task representing a value indicating if the edit session was started.
    Exceptions
    ExceptionDescription
    The project is not configured for editing single workspaces.
    A workspace is already being edited and has pending edits. Save or discard these edits first.
    A workspace is already being edited. Stop editing this workspace first.
    Remarks
    This method can only be used when EditingOptions.EnableEditingFromEditTab and EditingOptions.IsSingleWorkspaceEditSession are true. If the settings are not set then an System.InvalidOperationException will be thrown.
    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
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.6 or higher.
    See Also