PgRange
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Creates and parses typed PostgreSQL ranges without static members on generic types.
public static class PgRangeInheritance: object
Methods
Section titled “Methods”Create<T>(T, T, bool, bool)
Section titled “Create<T>(T, T, bool, bool)”Creates a range with inferred bound type, inclusive lower bound and exclusive upper bound by default.
public static PgRange<T> Create<T>(T lower, T upper, bool lowerInclusive = true, bool upperInclusive = false) where T : structType parameters:
T
The supported bound type.
Parameters:
lower — T
The lower bound.
upper — T
The upper bound.
lowerInclusive — bool
Whether the lower bound is included.
upperInclusive — bool
Whether the upper bound is included.
Returns: PgRange<T>
The uncanonicalized range.
Empty<T>()
Section titled “Empty<T>()”Creates an empty range without backend access.
public static PgRange<T> Empty<T>() where T : structType parameters:
T
The supported bound type.
Returns: PgRange<T>
The empty range.
FromRange(Range, int)
Section titled “FromRange(Range, int)”Resolves a .NET index range against a collection length and returns its half-open PostgreSQL integer interval.
public static PgRange<int> FromRange(Range range, int length)Parameters:
range — Range
The .NET range, including from-end indices.
length — int
The collection length used to resolve indices.
Returns: PgRange<int>
The integer interval, or empty for a zero-length slice.
Parse<T>(string)
Section titled “Parse<T>(string)”Parses and canonicalizes a built-in range using PostgreSQL on the active backend.
public static PgRange<T> Parse<T>(string text) where T : structType parameters:
T
The supported bound type.
Parameters:
text — string
The PostgreSQL range text.
Returns: PgRange<T>
The canonical range.
TryParse<T>(string?, out PgRange<T>?)
Section titled “TryParse<T>(string?, out PgRange<T>?)”Tries backend parsing, returning false for malformed bounds or subtype range errors.
public static bool TryParse<T>(string? text, out PgRange<T>? value) where T : structType parameters:
T
The supported bound type.
Parameters:
text — string
The PostgreSQL range text.
value — PgRange<T>
The canonical range, or null.
Returns: bool
Whether parsing succeeded.
For built-in range types, invalid input leaves no error pending: PostgreSQL 16 and later report it as a soft input error, and earlier majors roll back an internal subtransaction. Before PostgreSQL 16, transaction callbacks and parallel operations forbid that rollback; native errors there remain pending and throw PgException.
Unbounded<T>()
Section titled “Unbounded<T>()”Creates a fully unbounded range, distinct from empty and from SQL NULL.
public static PgRange<T> Unbounded<T>() where T : structType parameters:
T
The supported bound type.
Returns: PgRange<T>
The unbounded range.