This document is archived and information here might be outdated.  Recommended version.


IFeatureClass.Insert Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (GeoDatabase)  

IFeatureClass.Insert Method

Returns a cursor that can be used to insert new features.

[Visual Basic .NET]
Public Function Insert ( _
    ByVal useBuffering As Boolean _
) As IFeatureCursor
[C#]
public IFeatureCursor Insert (
    bool useBuffering
);
[C++]
HRESULT Insert(
  VARIANT_BOOL useBuffering,
  IFeatureCursor** Cursor
);
[C++]

Parameters useBuffering [in] useBuffering is a parameter of type VARIANT_BOOL Cursor [out, retval]
Cursor is a parameter of type IFeatureCursor

Product Availability

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

Remarks

Insert creates an insert cursor on the feature class which can be used to insert new features into it.

Insert cursors can be used on instances of feature subclasses (such as network features) with guaranteed polymorphic behavior. Insert cursors can be used either inside or outside of an edit session. If used inside an edit session, the changes are not committed to the base table until the edit session is saved. Network feature classes, Topology feature classes, feature classes that participate in composite relationships or other relationships with messaging may only be updated within an edit session. If you attempt to use an insert cursor on one of these classes outside of an edit session, it will fail. In addition, inserts of features that participate in a Topology or Geometric Network must be bracketed within an edit operation.

If the insert cursor is created outside of an edit operation and new features are inserted within an edit operation, the changes are commited to the base tables.  The additions to the base table cannot be undone.  For this reason, insert cursors should typically be scoped to edit operations.

When using an insert cursor with simple features, IFeature.Store will not be called when a feature is inserted. If a class extension, editor extension or other custom implementation relies on the messages propagated from the Store method, this could cause a problem. The IObjectClassInfo interface can be implemented by a class extension to force a Store call when an insert cursor is used. Alternately, requiring Store calls can be specified across a workspace by setting the IWorkspaceEditControl.SetStoreEventsRequired property to true.

If the insert cursor is used to insert complex features (such as network features), the cursor will revert to using IFeature.Store.

When using cursors within an edit session, they should always be scoped to edit operations. In other words, a cursor should be created after an edit operation has begun and should not be used once that edit operation has been stopped or aborted.

See Also

IFeatureClass Interface | IFeature Interface | IFeatureCursor Interface | IWorkspaceEdit Interface

.NET Samples

Extending the replication synchronization process (Code Files: RasterSyncWorkspaceExtension)

.NET Related Topics

Creating features | Geodatabase API best practices | How to access the features in an in-memory output layer using IFeatureCursor