PgArray<T>
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns a row-major PostgreSQL array, preserving up to six dimensions and their lower bounds. Use nullable value types for SQL NULL elements and nullable annotations for reference elements. A null array reference represents SQL NULL.
public sealed class PgArray<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerableType parameters:
T
A supported scalar element type, such as int?, string, PgNumeric, or a registered datum mapping.
Inheritance: object
Implements: IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Constructors
Section titled “Constructors”PgArray(IEnumerable<T>)
Section titled “PgArray(IEnumerable<T>)”Copies a vector. Nonempty vectors have one dimension with lower bound one.
public PgArray(IEnumerable<T> values)Parameters:
values — IEnumerable<T>
The elements in order.
PgArray(ReadOnlySpan<T>, ReadOnlySpan<int>, ReadOnlySpan<int>)
Section titled “PgArray(ReadOnlySpan<T>, ReadOnlySpan<int>, ReadOnlySpan<int>)”Copies elements and dimensions. Empty arrays normalize to PostgreSQL’s zero-dimensional empty array.
public PgArray(ReadOnlySpan<T> values, ReadOnlySpan<int> lengths, ReadOnlySpan<int> lowerBounds = default)Parameters:
values — ReadOnlySpan<T>
The row-major elements; the last subscript varies fastest.
lengths — ReadOnlySpan<int>
Zero through six dimension lengths whose product equals the element count.
lowerBounds — ReadOnlySpan<int>
One lower bound per dimension, or an empty span to use one for every dimension.
Properties
Section titled “Properties”Gets the total element count, including SQL NULL elements.
public int Count { get; }Value: int
ElementTypeOid
Section titled “ElementTypeOid”Gets the PostgreSQL element identity, including the named composite identity of an empty or all-null array. Enum, custom type and registered datum identities are resolved in the current backend when requested.
public uint ElementTypeOid { get; }Value: uint
this[int]
Section titled “this[int]”Gets an element by its zero-based flat index, independently of PostgreSQL lower bounds.
public T this[int index] { get; }Parameters:
index — int
The row-major index.
Value: T
The element.
Lengths
Section titled “Lengths”Gets the dimension lengths without exposing mutable storage.
public ReadOnlySpan<int> Lengths { get; }Value: ReadOnlySpan<int>
LowerBounds
Section titled “LowerBounds”Gets the PostgreSQL lower bounds without exposing mutable storage.
public ReadOnlySpan<int> LowerBounds { get; }Value: ReadOnlySpan<int>
Gets the number of dimensions. PostgreSQL empty arrays have rank zero.
public int Rank { get; }Value: int
Methods
Section titled “Methods”GetEnumerator()
Section titled “GetEnumerator()”Enumerates elements in row-major order.
public IEnumerator<T> GetEnumerator()Returns: IEnumerator<T>
The enumerator.
GetValue(params ReadOnlySpan<int>)
Section titled “GetValue(params ReadOnlySpan<int>)”Gets an element by PostgreSQL subscripts, including negative and non-one lower bounds.
public T GetValue(params ReadOnlySpan<int> subscripts)Parameters:
subscripts — ReadOnlySpan<int>
Exactly one subscript per dimension.
Returns: T
The element.
ToArray()
Section titled “ToArray()”Copies all elements in row-major order, explicitly discarding shape and lower bounds.
public T[] ToArray()Returns: T[]
A flat managed array.
ToVector()
Section titled “ToVector()”Copies a zero- or one-dimensional array with lower bound one, rejecting shape loss.
public T[] ToVector()Returns: T[]
The managed vector.