DisposableCursor Class

Wrapper class of a disposable ICursor which will automatically release the ICursor after the cursor is used.

Usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    ICursor rowCursor = table.Search(null, false);
    using (DisposableCursor dispCursor = new DisposableCursor(rowCursor))
    {
        IEnumerable<IRow> rows = dispCursor.AsEnumerable();
        foreach (IRow f in rows)
        {
            // perform your operation
        }
    }
    //Get a new instance of the cursor rowCursor2. You can't reuse the existing rowCursor.
    ICursor rowCursor2 = table.Search(null, false);
    using (DisposableCursor dispCursor = rowCursor2.ToDisposable())
    {
        IEnumerable<IRow> rows = dispCursor.AsEnumerable();
        int cnt = rows.Count();
    }

Constructors

NameDescription
DisposableCursor(ICursor)Initializes a DisposableCursor.

DisposableCursor(ICursor) Constructor

Creates a DisposableCursor from ICursor object. Note that a DisposableCursor cannot be wrapped or instantiated in another DisposableCursor instance, otherwise, an ArgumentException "Unable to wrap DisposableCursor in another DisposableCursor instance." will be thrown by the constructor.

1
public DisposableCursor(ICursor cursor)
Parameter nameTypeDescription
cursorICursorThe cursor to be made disposable.

Property

PropertyProperty valueDescription
DisposableCursor.FieldsIFieldsThe Fields Collection for this cursor. See ICursor.Fields

Methods

NameDescription
DisposableCursor.DisposeRelease the cursor explicitly to avoid leaking database resources.
DisposableCursor.DeleteRowDelete the existing Row in the database corresponding to the current position of the cursor.
DisposableCursor.FindField(String)Find the index of the field with the specified name.
DisposableCursor.FlushFlush any outstanding buffered writes to the database.
DisposableCursor.InsertRow(IRowBuffer)Insert a new Row into the database using the property values in the input buffer.
DisposableCursor.NextRowAdvance the position of the cursor by one and return the Row object at that position.
DisposableCursor.UpdateRow(IRow)Update the existing Row in the database corresponding to the current position of the cursor.

DisposableCursor.Dispose Method

Release the cursor to avoid leaking database resources.

1
public void Dispose()

DisposableCursor.DeleteRow Method

Delete the existing Row in the database corresponding to the current position of the cursor. See ICursor.DeleteRow.

1
public void DeleteRow()

DisposableCursor.FindField(String) Method

Find the index of the field with the specified name. See ICursor.FindField.

1
public int FindField(string name)

DisposableCursor.Flush Method

Flush any outstanding buffered writes to the database. See ICursor.Flush.

1
public void Flush()

DisposableCursor.InsertRow(IRowBuffer) Method

Insert a new Row into the database using the property values in the input buffer. The object ID of the new Row, if there is one, is returned. See ICursor.InsertRow.

1
public object InsertRow(IRowBuffer buffer)

DisposableCursor.NextRow Method

Advance the position of the cursor by one and return the Row object at that position. See ICursor.NextRow.

1
public IRow NextRow()

DisposableCursor.UpdateRow(IRow) Method

Update the existing Row in the database corresponding to the current position of the cursor. See ICursor.UpdateRow.

1
public void UpdateRow(IRow row)

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close