PgRange<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns the bounds of a built-in or explicitly mapped PostgreSQL range. A null reference is SQL NULL; a parameterless instance is empty. Construction retains the requested bounds. PostgreSQL validates and canonicalizes them on datum conversion.
public sealed class PgRange<T> : IEquatable<PgRange<T>> where T : structType parameters:
T
A supported built-in bound or a closed value type declaring both PgDatumType and PgRangeType.
Inheritance: object
Implements: IEquatable<PgRange<T>>
Constructors
Section titled “Constructors”PgRange()
Section titled “PgRange()”Creates an empty range of the supported bound type.
public PgRange()PgRange(T?, T?, bool, bool)
Section titled “PgRange(T?, T?, bool, bool)”Creates a bounded or unbounded range without backend access. Null bounds mean unbounded ends.
public PgRange(T? lower, T? upper, bool lowerInclusive = true, bool upperInclusive = false)Parameters:
lower — T?
The lower value, or null for an unbounded end.
upper — T?
The upper value, or null for an unbounded end.
lowerInclusive — bool
Whether the lower value is included; ignored when unbounded.
upperInclusive — bool
Whether the upper value is included; ignored when unbounded.
Methods
Section titled “Methods”Canonicalize()
Section titled “Canonicalize()”Validates and canonicalizes the bounds using PostgreSQL on the active backend.
public PgRange<T> Canonicalize()Returns: PgRange<T>
The canonical range, which can be empty even when this instance is not.
Contains(PgRange<T>)
Section titled “Contains(PgRange<T>)”Tests whether this range contains another range on the active backend.
public bool Contains(PgRange<T> other)Parameters:
other — PgRange<T>
The candidate range.
Returns: bool
Whether it is contained.
Contains(T)
Section titled “Contains(T)”Tests value containment using PostgreSQL’s subtype ordering and canonical range semantics.
public bool Contains(T value)Parameters:
value — T
The candidate value.
Returns: bool
Whether the range contains the value.
Equals(PgRange<T>?)
Section titled “Equals(PgRange<T>?)”Compares stored bounds and inclusion flags without backend access or canonicalization.
public bool Equals(PgRange<T>? other)Parameters:
other — PgRange<T>
The other range.
Returns: bool
Whether their stored representations are equal.
Equals(object?)
Section titled “Equals(object?)”public override bool Equals(object? obj)Parameters:
obj — object
Returns: bool
Except(PgRange<T>)
Section titled “Except(PgRange<T>)”Subtracts a range. PostgreSQL raises an error if the result would require two separate ranges.
public PgRange<T> Except(PgRange<T> other)Parameters:
other — PgRange<T>
The range to subtract.
Returns: PgRange<T>
The canonical difference.
GetHashCode()
Section titled “GetHashCode()”public override int GetHashCode()Returns: int
Intersect(PgRange<T>)
Section titled “Intersect(PgRange<T>)”Intersects two ranges on the active backend.
public PgRange<T> Intersect(PgRange<T> other)Parameters:
other — PgRange<T>
The other range.
Returns: PgRange<T>
The intersection, possibly empty.
IsAdjacentTo(PgRange<T>)
Section titled “IsAdjacentTo(PgRange<T>)”Tests whether two ranges are adjacent on the active backend.
public bool IsAdjacentTo(PgRange<T> other)Parameters:
other — PgRange<T>
The other range.
Returns: bool
Whether the ranges are adjacent.
Merge(PgRange<T>)
Section titled “Merge(PgRange<T>)”Returns the smallest range spanning both operands, including any gap between them.
public PgRange<T> Merge(PgRange<T> other)Parameters:
other — PgRange<T>
The other range.
Returns: PgRange<T>
The spanning range.
Overlaps(PgRange<T>)
Section titled “Overlaps(PgRange<T>)”Tests whether two ranges overlap on the active backend.
public bool Overlaps(PgRange<T> other)Parameters:
other — PgRange<T>
The other range.
Returns: bool
Whether the ranges overlap.
ToPostgresString()
Section titled “ToPostgresString()”Formats the canonical range using PostgreSQL on the active backend, including session temporal settings.
public string ToPostgresString()Returns: string
The PostgreSQL range text.
ToString()
Section titled “ToString()”Describes the stored bounds without backend access or canonicalization. Use ToPostgresString for SQL input text.
public override string ToString()Returns: string
A diagnostic representation using the bound types’ formatting.
Union(PgRange<T>)
Section titled “Union(PgRange<T>)”Unites overlapping or adjacent ranges. PostgreSQL raises an error if the result would be disjoint.
public PgRange<T> Union(PgRange<T> other)Parameters:
other — PgRange<T>
The other range.
Returns: PgRange<T>
The canonical union.
Properties
Section titled “Properties”IsEmpty
Section titled “IsEmpty”Gets whether this value represents an empty range rather than an interval with bounds.
public bool IsEmpty { get; }Value: bool
IsUnbounded
Section titled “IsUnbounded”Gets whether the nonempty range has no lower or upper bound.
public bool IsUnbounded { get; }Value: bool
Gets the lower bound, or null for an empty range or unbounded lower end.
public T? Lower { get; }Value: T?
LowerInclusive
Section titled “LowerInclusive”Gets whether the present lower bound is included, including an explicit subtype infinity value.
public bool LowerInclusive { get; }Value: bool
Gets the upper bound, or null for an empty range or unbounded upper end.
public T? Upper { get; }Value: T?
UpperInclusive
Section titled “UpperInclusive”Gets whether the present upper bound is included, including an explicit subtype infinity value.
public bool UpperInclusive { get; }Value: bool