AnsweredAssumed Answered

IFeatureClass.CreateFeature() creates directly a feature but why?

Question asked by kaspatoo on Apr 3, 2012
Latest reply on Apr 4, 2012 by kaspatoo
Hello,

I want to create a feature, so I do
IFeature newFeature = analyseFeatureClass.CreateFeature();


when reading this page:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/CreateFeature_Method/0025000002sz000000/
explicitiy this sentence: Use the IFeature::Store method to actually store this new feature in the database.
and
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000049v000000
Store the feature???The feature is not written to the database until the IFeature.Store method has been called.
I would expect that I will get an IFeature object back from calling this method.
I also expect that this feature is not stored in my featureClass (at runtime)/ Geodatabase(after application closes) until I call IFeature.Store().

I debugged my program. Here's the log:
//before calling createFeature: 141 features in FeatureClass //Calling IFeatureClass.CreateFeature() //after calling createFeature: 142 features in FeatureClass


So after this single line the feature is still stored. Also when I directyl abort the whole program after this. There's no Feature.Store Method at all in my code.
I took the way to store my features by using an insertCursor, casting my created feature to a featureBuffer.
Due to this every feature is stored twice in my database.
the first one of each pair (through createFeature-method) does not contain any values, so it has null values (like documentation says, but wouthout the fact its really stored directly)
the second one contains the values I defined but is then stored as own feature getting its own OID.

So I guess that the calling createFeature method stored the feature directly to the featureClass but not to the database. When calling featureCurso.flush is called all featurebuffer plus all created features are stored then. If this is right I think the createFeature method does something like adding the feature to the featureBuffer query like using the featureCursor.insert(featureBuffer) method.

I think the simpliest solution not to make much changes to my code is to make use of IFeatureClass.CreateFeatureBuffer instead of createFeature. But if all what I am saying is right, then where's the difference of using createFeature followed by FeatureCurso.Flush() and using the correct Featurebuffer? And why the **** does ESRI documentation not offer or prevent developers from using this way of life?

Thanks for any useful answer!

Outcomes