English

Problem: Calling IFeatureClass.FeatureCount(Nothing) within an edit operation returns incorrect count with an ArcSDE geodatabase

Description

The following scenario causes IFeatureClass.FeatureCount(Nothing) to return the incorrect results.

1. Call IEditor.StartOperation.
2. Add or delete features.
3. Call IFeatureClass.FeatureCount(Nothing).
4. Call IEditor.StopOperation.

The count will not include the additions or deletions made within the edit operation.

Cause

Issuing IFeatureClass.FeatureCount without a spatial query does not flush the edit cache before querying the database for the number of features.

Solution or Workaround

Call IEditor.StopOperation prior to calling IFeatureClass.FeatureCount(Nothing). So, the scenario from above should be like this:

  1. Call IEditor.StartOperation.
  2. Add or delete features.
  3. Call IEditor.StopOperation.
  4. Call IFeatureClass.FeatureCount(Nothing).