Cursor provides methods for iterating through list and index results for instances of a class.
public enum Operation {
LessThan, LessOrEquals, Equals, GreaterOrEquals, GreaterThan,
Overlaps, Contains, ExactMatch, BestMatch, PrefixMatch,
NextMatch, Neighbourhood, StrictEquals, IsPrefixOf, ContainsAll, ContainsAny
}
public interface ICursor : IEnumerable, IEnumerator {
bool Checkpoint();
void Update();
void Remove();
long GetAutoId();
}
public class Cursor<T> : ICursor, IEnumerable<T>, IEnumerator<T> where T : class
{
// --- Constructors ---
public Cursor(Connection con, String indexName);
public Cursor(Connection con);
// --- Properties ---
public T Current { get; }
// --- Enumerator Methods ---
public IEnumerator<T> GetEnumerator();
// --- Search & Query Methods ---
public bool Search(Operation op, params Object[] val);
public T Find(params Object[] val);
public bool QueryByExample(object from, object till);
// --- Navigation Methods ---
public bool MoveFirst();
public bool MoveLast();
public bool MoveNext();
public bool MovePrev();
public T Skip(int offset);
// --- Data Modification Methods ---
public void Update();
public void Remove();
public bool Checkpoint();
// --- Utility Methods ---
public long GetAutoId();
public void Store();
public void Close();
public void Reset();
public void Dispose();
// --- Nested Public Enums ---
public enum Position { Unknown, Empty, First, Curr, DeleteNext, DeletePrev }
public enum Direction { Unknown, Forward, Backward }
}
Operation enumICursor.Checkpoint()
false if an MVCC conflict occurs.ICursor.Update()
MoveFirst(), MoveLast(), MoveNext(), MovePrev(), or Skip().ICursor.Remove()
ICursor.GetAutoId()
Cursor(Connection con, String indexName)
T using the specified named index. Inheritance relationships are not considered.Cursor(Connection con)
T using the class's list or AUTOID index. The class must declare [Persistent(List=true)], [Persistent(AutoID=true)], or both.Current
T at the cursor position. Returns null if no valid current object exists.GetEnumerator()
Search(Operation op, params Object[] val)
Equals, StrictEquals), BTree (comparison), RTree (spatial), Patricia (pattern), and Trigram (Contains). ContainsAll and ContainsAny apply to thick array indexes.Find(params Object[] val)
Search(Equals, value) followed by MoveNext(). Returns the matching object or default(T) if not found.QueryByExample(object from, object till)
from define inclusive lower bounds; fields in till define inclusive upper bounds.MoveFirst()
true if the set is not empty.MoveLast()
true if the set is not empty.MoveNext()
true if successful, false if no more objects remain.MovePrev()
true if successful, false if no more objects remain.Skip(int offset)
default(T) if unreachable.Update()
Remove()
Checkpoint()
false if an MVCC conflict prevents the operation.GetAutoId()
Store()
Close()
Reset()
MoveNext(), MoveFirst(), or MoveLast() can position it again.Dispose()
Close() when you need to close the underlying cursor handle.Position enumUnknown, Empty, First, Curr, DeleteNext, DeletePrev.Direction enumUnknown, Forward, Backward.