Table of Contents

Struct NpgsqlCube

Namespace
NpgsqlTypes
Assembly
Npgsql.dll

Represents a PostgreSQL cube data type.

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

Remarks

Constructors

NpgsqlCube(NpgsqlCube, double)

Makes a new cube by adding a dimension on to an existing cube, with the same values for both endpoints of the new coordinate. This is useful for building cubes piece by piece from calculated values.

public NpgsqlCube(NpgsqlCube cube, double coord)

Parameters

cube NpgsqlCube

The existing cube.

coord double

The coordinate to add.

NpgsqlCube(NpgsqlCube, double, double)

Makes a new cube by adding a dimension on to an existing cube. This is useful for building cubes piece by piece from calculated values.

public NpgsqlCube(NpgsqlCube cube, double lowerLeft, double upperRight)

Parameters

cube NpgsqlCube

The existing cube.

lowerLeft double

The lower left value.

upperRight double

The upper right value.

NpgsqlCube(IEnumerable<double>)

Makes a zero-volume cube using the coordinates defined by the array.

public NpgsqlCube(IEnumerable<double> coords)

Parameters

coords IEnumerable<double>

The coordinates.

NpgsqlCube(IEnumerable<double>, IEnumerable<double>)

Makes a cube with upper right and lower left coordinates as defined by the two arrays, which must be of the same length.

public NpgsqlCube(IEnumerable<double> lowerLeft, IEnumerable<double> upperRight)

Parameters

lowerLeft IEnumerable<double>

The lower left values.

upperRight IEnumerable<double>

The upper right values.

Exceptions

ArgumentException

Thrown if the number of dimensions in the upper left and lower right values do not match or if the cube exceeds the maximum dimensions (100).

NpgsqlCube(double)

Makes a one dimensional cube with both coordinates the same.

public NpgsqlCube(double coord)

Parameters

coord double

The point coordinate.

NpgsqlCube(double, double)

Makes a one dimensional cube.

public NpgsqlCube(double lowerLeft, double upperRight)

Parameters

lowerLeft double

The lower left value.

upperRight double

The upper right value.

Properties

Dimensions

The number of dimensions of the cube.

public int Dimensions { get; }

Property Value

int

IsPoint

True if the cube is a point, that is, the two defining corners are the same.

public bool IsPoint { get; }

Property Value

bool

LowerLeft

The lower left coordinates of the cube.

public IReadOnlyList<double> LowerLeft { get; }

Property Value

IReadOnlyList<double>

UpperRight

The upper right coordinates of the cube.

public IReadOnlyList<double> UpperRight { get; }

Property Value

IReadOnlyList<double>

Methods

Equals(NpgsqlCube)

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

public bool Equals(NpgsqlCube other)

Parameters

other NpgsqlCube

An object to compare with this object.

Returns

bool

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

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.

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.

ToString()

Writes the cube in PostgreSQL's text format.

public override string ToString()

Returns

string

ToSubset(params int[])

Makes a new cube from an existing cube, using a list of dimension indexes from an array. Can be used to extract the endpoints of a single dimension, or to drop dimensions, or to reorder them as desired.

public NpgsqlCube ToSubset(params int[] indexes)

Parameters

indexes int[]

The list of dimension indexes.

Returns

NpgsqlCube

A new cube.

Examples

var cube = new NpgsqlCube(new[] { 1, 3, 5 }, new[] { 6, 7, 8 }); // '(1,3,5),(6,7,8)'
cube.ToSubset(1); // '(3),(7)'
cube.ToSubset(2, 1, 0, 0); // '(5,3,1,1),(8,7,6,6)'

Operators

operator ==(NpgsqlCube, NpgsqlCube)

Defines a generalized method that a value type or class implements to create a type-specific method for determining equality of instances.

public static bool operator ==(NpgsqlCube x, NpgsqlCube y)

Parameters

x NpgsqlCube
y NpgsqlCube

Returns

bool

operator !=(NpgsqlCube, NpgsqlCube)

Defines a generalized method that a value type or class implements to create a type-specific method for determining equality of instances.

public static bool operator !=(NpgsqlCube x, NpgsqlCube y)

Parameters

x NpgsqlCube
y NpgsqlCube

Returns

bool