Table of Contents

Struct CursorToken

Namespace
Tharga.MongoDB.Paging
Assembly
Tharga.MongoDB.dll

Opaque cursor identifying a boundary document in a keyset-paginated query. Carries the sort-field path, sort direction, the sort-field value at the boundary, and the document _id (used as a tiebreaker on non-unique sort fields). Round-trip via ToString() + Parse(string) for URL-safe storage.

public readonly struct CursorToken : IEquatable<CursorToken>
Implements
Inherited Members

Properties

Empty

Sentinel for "no cursor" — used as the boundary value in CursorPage<T> when there are no items.

public static CursorToken Empty { get; }

Property Value

CursorToken

IsEmpty

True when this token is the Empty sentinel.

public bool IsEmpty { get; }

Property Value

bool

Methods

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(CursorToken)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CursorToken other)

Parameters

other CursorToken

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

From<TEntity, TKey>(TEntity, Expression<Func<TEntity, object>>, bool)

Construct a cursor that points at entity under the given sort. Used by adapter code that falls back to skip-based queries (e.g. arbitrary page-number jumps) and then needs to resume keyset navigation from the boundary documents. sortBy = null creates an _id-only cursor.

public static CursorToken From<TEntity, TKey>(TEntity entity, Expression<Func<TEntity, object>> sortBy, bool ascending) where TEntity : EntityBase<TKey>

Parameters

entity TEntity
sortBy Expression<Func<TEntity, object>>
ascending bool

Returns

CursorToken

Type Parameters

TEntity
TKey

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Parse(string)

Parse a cursor from its ToString() form. Throws FormatException for malformed input. An empty or null string returns Empty.

public static CursorToken Parse(string s)

Parameters

s string

Returns

CursorToken

ToString()

URL-safe string form. Round-trips with Parse(string).

public override string ToString()

Returns

string

Operators

operator ==(CursorToken, CursorToken)

public static bool operator ==(CursorToken left, CursorToken right)

Parameters

left CursorToken
right CursorToken

Returns

bool

operator !=(CursorToken, CursorToken)

public static bool operator !=(CursorToken left, CursorToken right)

Parameters

left CursorToken
right CursorToken

Returns

bool