Wrapper class of a disposable ICursor which will automatically release the ICursor after the cursor is used.
Usage:
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
Name | Description |
---|---|
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.
public DisposableCursor(ICursor cursor)
Parameter name | Type | Description |
---|---|---|
cursor | ICursor | The cursor to be made disposable. |
Property
Property | Property value | Description |
---|---|---|
DisposableCursor.Fields | IFields | The Fields Collection for this cursor. See ICursor.Fields |
Methods
Name | Description |
---|---|
DisposableCursor.Dispose | Release the cursor explicitly to avoid leaking database resources. |
DisposableCursor.DeleteRow | Delete 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.Flush | Flush 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.NextRow | Advance 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.
public void Dispose()
DisposableCursor.DeleteRow Method
Delete the existing Row in the database corresponding to the current position of the cursor. See ICursor.DeleteRow.
public void DeleteRow()
DisposableCursor.FindField(String) Method
Find the index of the field with the specified name. See ICursor.FindField.
public int FindField(string name)
DisposableCursor.Flush Method
Flush any outstanding buffered writes to the database. See ICursor.Flush.
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.
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.
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.
public void UpdateRow(IRow row)