6

I am working with some feature classes. I create those feature classes using my add-in. User can add/ delete features from these feature classes clicking on "add", "delete" buttons and selecting features. I added features using following code:

void AddFeature(IFeatureClass featureClass, IGeometry geometry)
{
 IFeature feature = featureClass.CreateFeature();
 feature.Shape = geometry;
 feature.Store();
}

And deleted features using following code:

void DeleteFeaturesWithinPolygon(IFeatureClass featureClass, IPolygon polygon)
{
 List<IFeature> features = GetFeaturesWithinPolygon(featureClass, polygon);
 foreach (var feature in features)
 feature.Delete();
}

Thing is, I did not use editor session. And actually, I did not think about it earlier. but today seeing this question, I think about edit session. I know can do these edits, without edit session. Actually I am doing it right now.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 28, 2013 at 5:26
1
  • After doing work with IEditor, I feel that most amazing thing of this is decreasing significant amount of time. When I updated 13k features, time reduces from 20 minutes to 1 minute. Commented Apr 24, 2013 at 5:48

3 Answers 3

6

I recommend starting and finishing all edits within an edit operation inside of a try block, where a catch block would call AbortOperation.

Something I've always wondered about is whether it makes sense before starting an edit operation to check to see if there's already an operation underway, via IWorkspaceEdit2.IsInEditOperation.

answered Jan 28, 2013 at 21:11
1
  • But if I do edit in the way I am doing now, is it wrong or is there any kind of problem? Commented Jan 29, 2013 at 3:37
5

The benefit of starting an edit session is that you can use the many different edit event listeners to control edit workflow if needed. You also have the ability to undo edits if a feature was deleted by mistake.

answered Jan 28, 2013 at 20:18
3

I think this document will provide to you a good source of knowledge: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000340000000

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Jan 28, 2013 at 19:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.