1

I'm developing an ArcMap addin with ArcObjects 10.3.1 SDK that needs to have an active edit session to work.

It creates new rows after a check process and stores them in a datatable into a file Geodatabase.

Like that:

// Initialize new row
errorRow = errorsTable.CreateRow();
// Fill row
...
// Commiting the new feature storage
errorRow.Store();
// Iterate over all check results then save edit session
((IWorkspaceEdit)m_featureWorkspace).StopEditing(true);
((IWorkspaceEdit)m_featureWorkspace).StartEditing(true);

My problem is I don't want the addin to rely on a programmatical save edits, since the user might be running other processes at this same edit session.

I then tried to use the method ExecuteSQL from IWorkspace interface in hopes it would turn to be a direct insertion bypassing the edit session, but with no avail.

string sqlStatement = string.Format(new 
    System.Globalization.CultureInfo("en-US"), "INSERT INTO {0} VALUES (...);", ...);
((IWorkspace)m_featureWorkspace).ExecuteSQL(sqlStatement);

// Needs a save edits
((IWorkspaceEdit)m_featureWorkspace).StopEditing(true);
((IWorkspaceEdit)m_featureWorkspace).StartEditing(true);

Is there any way to programatically bypass an active edit session to insert rows into the database without having to mandatorily save a whole active edit session?

8
  • 1
    Not sure this is viable but have a look at creating insert cursors. Note the usage comment at the bottom of page. – Hornbydd Oct 5 '17 at 10:34
  • @Hornbydd Nice one, thanks. I've tried it but neither Insert() bypasses edit session. I'd just upvote your comment if I could because its significant performance increase over Create() and Store() in this scope. – Jose Oct 5 '17 at 11:33
  • I am not aware of a way around an edit session. Does the user know this is running? Does the user know when it is finished? It may be best to let the user worry about saving the edits made by your addin. – danielm Oct 6 '17 at 14:23
  • @danielm Yeah but I didn't want to delegate the task to the user. I agree it is the only viable option in my scenario. Thanks. – Jose Oct 6 '17 at 14:34
  • 1
    Just thinking aloud. The typical work flow in ArcMap is that the user starts/ends the editing session. This is what is expected by the user. To silently start and stop editing seems like a dangerous route to go as a user could potentially corrupt the data without their knowledge. I think educating your user and providing a decent help file for your custom tool is a more robust way of doing things. It really is NO EFFORT to start\ stop editing, especially if they then go on and do complex editing of geometries? – Hornbydd Oct 6 '17 at 14:53
1

Workaround: I ended up adding my own edit session control in a custom toolbar. The user is asked if he wants to start an edit session, and save current edits or just close the addin when untoggling it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.