Editing Data#
There is a lot of editing that takes place within the ESRI platform. You can easily wrap up the necessary stop / start operations using the different flavors of the PerformOperation
extension method on the IWorkspace
, IWorkspaceEdit
, IVersion
, and IEditor
interfaces.
Method | Description |
---|---|
PerformOperation(bool, Func<bool>) |
Encapsulates the operation in the necessary start and stop constructs. |
PerformOperation(bool, esriMultiusreEditSessionMode, Func<bool>) |
Encapsulates the operation in necessary start and stop edit constructs with the ability to undo the operation and control if versioned or non-versioned data should be edited. |
PerformOperation(bool, Func<bool>, Func<COMException>) |
Encapsulates the operation in necessary start and stop edit constructs with the ability to undo the operation and allows for handling errors when saving the operation. |
Nonversioned Edits#
There are situations when you need to update only non-versioned tables inside the GIS. You can use the following method, and specific the proper enumeration to ensure that you are only editing the non-versioned tables inside the workspace.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Update the description of Denver, in the City table that is a non-versioned table. workspace.PerformOperation(true, esriMultiuserEditSessionMode.esriMESMNonVersioned, ()=> { var cities = workspace.GetTable(typeof(City)); var filter = new QueryFilter(); filter.Where = "City = 'Denver'"; var denver = cities.Map<City>(filter).SingleOrDefault(); denver.Description = "The capital of Colorado."; denver.Update(); return true; // Commit the operation. }); |
Versioned Edits#
When editing a version table or feature class, you can take the same actions as above, except specify the versioned enumeration.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Update the Begin and End stationing values for the Route with the ID. workspace.PerformOperation(true, esriMultiuserEditSessionMode.esriMESMVersioned, ()=> { var route = workspace.GetFeatureClass(typeof(RouteCenterline)); var filter = new QueryFilter(); filter.Where = "ROUTEID = 10423"; var centerline = route.Map<RouteCenterline>(filter).SingleOrDefault(); centerline.Begin = 0; centerline.End = 100; centerline.Update(); return true; // Commit the operation. }); |