ArcObjects Library Reference (GeoDatabase)  

IWorkspaceEdit Interface

Provides access to members that control Workspace Editing. Note: the IWorkspaceEdit interface has been superseded byIWorkspaceEdit2. Please consider using the more recent version.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Members

Description
Method AbortEditOperation Aborts an edit operation.
Method DisableUndoRedo Disables Undo and Redo of edit operations.
Method EnableUndoRedo Enables Undo and Redo of edit operations.
Method HasEdits True if there are any completed edit operations that need to be saved .
Method HasRedos True if there are any completed undos that can be redone.
Method HasUndos True if there are any completed edit operations that can be undone.
Method IsBeingEdited True if the workspace is being edited.
Method RedoEditOperation Causes a Redo to be performed on the last undo.
Method StartEditing Starts editing the workspace.
Method StartEditOperation Begins an edit operation.
Method StopEditing Stops editing the workspace.
Method StopEditOperation Ends an edit operation.
Method UndoEditOperation Causes an Undo to be performed on the last edit operation.

CoClasses that implement IWorkspaceEdit

CoClasses and Classes Description
VersionedWorkspace VersionedWorkspace Object.
Workspace Workspace Object.

Remarks

The IWorkspaceEdit interface allows the application to start and stop edit sessions during which the objects in a geodatabase can be updated. An edit session corresponds to a long transaction. To start a non-versioned edit session against an ArcSDE datasource the IMultiuserWorkspaceEdit interface should be used. In fact, when programmatically editing objects within a ArcSDE database it is recommended that the IMultiuserWorkspaceEdit interface be used. The only data changes an application sees within an edit session are changes that are made by the application. Changes made by other concurrently executing applications (if allowed) are not seen until the edit session is saved or discarded.

When required to insert, update or delete objects, it is strongly recommended to perform the operation using an edit session and within an edit operation. Although (in most cases) these operations can be performed without explicitly starting and stopping an edit operation, the resulting change will be non-deterministic in respect to which state of the database the operation is associated or even the possibility of encountering an error when the change can not be applied to an open state. For these reasons all edits should be performed within an edit operation.

The geodatabase guarantees ‘unique instancing’ of row objects retrieved from the database within an edit session. Any data access call that retrieves a non-recycling object with a particular object ID will return the in memory instance of the object if the object has already been instantiated by the application. Such behavior is needed to ensure application correctness when updating complex object models—for example, models with relationship-based messaging or models with network features where updates to the geometry of a feature affect the geometry of topologically related features.

For this reason all object editing should be done within an edit session. The geodatabase data update APIs (such as IRow::Store, ITable::Update, and ITable::Insert ) will fail if you attempt to use them outside of an edit session on object and feature classes that are marked as requiring an edit session to ensure unique instancing semantics.

The geodatabase does not support nested transactions. When editing in a versioned environment on a SDE geodatabase only one transaction should be open at any one time. This means that if the same connection is used to edit multiple versions it is good practice to call StopEditing on the first edit session prior to calling StartEditing on another version. If another transaction is opened prior to closing the first transaction an open transaction error will be returned to the application. Programmatically this can be avoided by calling IsBeingEdited prior to StartEditing

Applications should be aware that DDL (data definition language) operations made through ArcObjects geodatabase data access objects (for example, deleting feature dataset or creating a new feature class) use database transactions to ensure integrity of the data dictionary tables and commit the transaction at the end of the operation. Applications should not invoke DDL operations within an application transaction—application transactions should be restricted to DML operations (such as data updates).

The rules for correct object editing on a geodatabase are summarized below:

  1. All object editing should be done within an edit session.
  2. Group changes into edit operations.
  3. Discard all references to row objects retrieved at the edit session boundary (on StartEditing). If references to row objects will be maintained across edit operations then discard all references and refetch objects in response to the Undo, redo and abort edit operation calls made by the application as well as the reconcile call made within an edit session on versioned databases. In the context of ArcMap, these calls are made by the editor which broadcasts corresponding editor events via the IEditorEvents and IEditorEvents2 interfaces. Personal and enterprise geodatabase workspaces support the IWorkspaceEditEvents and the IVersionEvents outbound interfaces and directly broadcast these events.
  4. Use non-recycling search cursors to fetch objects that are to be updated (using any of the Search, GetRow, or GetRows methods supported by tables, feature classes and selection sets). Recycling cursors should be used only for drawing and read-only access to object state.
  5. Always fetch all properties of the objects to be edited. Query filters should always use “*” for the sub fields property (attempts to instantiate non-recycling cursors with less than all fields will still result in all row object fields being hydrated).
  6. After changing a row object, mark the object as changed and trigger propagation of the OnChanged message, as well as propagation of messages to related objects by calling the IRow::Store method on the object. Delete objects by calling the IRow::Delete method on the object triggering the OnDelete message. Stored and deleted objects within an edit operation are automatically and periodically flushed to the underlying database as needed to ensure read/query consistency and update efficiency. Use the set versions of these methods (for example, IRowEdit::DeleteSet) if updates or deletes are being made to a set of objects in order to increase performance.
  7. Update and insert cursors are bulk data loading and data update API’s designed for performing direct updates and inserts, outside of an edit session, on simple data, during the data loading phase of a project. Avoid using these API’s in editing applications. Using these API’s within an edit session or on complex objects (objects with non-simple row or feature behavior or on objects participating in composite relationships or relationships with notification) negates any performance advantages they may have. For more information related to the above rules, see the documentation in this chapter on rows, objects, features tables, object classes, and feature classes.

See Also

IVersionEdit Interface | IWorkspaceEditEvents Interface

.NET Samples

Bind a geodatabase table to a .NET control (Code Files: FieldPropertyDescriptor TableWrapper)

.NET Related Topics

Adjusting feature locations with spatial adjustment | Editing with the geodatabase API | Geodatabase | Geodatabase API best practices | GeoDatabaseUI | How to load a raster dataset to the raster field in a feature class | Reconciling versions