Skip to content

Commit 64dc765

Browse files
committed
Cube docs
1 parent be1c2a1 commit 64dc765

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

conceptual/EFCore.PG/release-notes/10.0.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ For more information, [see the documentation](../modeling/generated-properties.m
136136

137137
By default, EF generates GUID (or UUID) values locally in .NET, rather than relying on the database to generate them. Version 9 of the PG provider already switched to generating UUIDv7 values by default ([see release note](9.0.md#uuidv7-guids-are-generated-by-default)), which are significantly better for database indexes. PostgreSQL 18 also added the [`uuidv7()`](https://www.postgresql.org/docs/18/functions-uuid.html#FUNC_UUID_GEN_TABLE) built-in function, which allows database generation of UUIDv7 values. In EFCore.PG 10, if you configure the provider to target PG 18 (`.UseNpgsql("...", o => o.SetPostgresVersion(18, 0))`), the provider will also translate [`Guid.CreateVersion7()`](https://learn.microsoft.com/dotnet/api/system.guid.createversion7) to that function.
138138

139+
## Support for the cube extension
140+
141+
PostgreSQL bundles the [`cube`](https://www.postgresql.org/docs/current/cube.html) extension, which provides a multi-dimensional cube data type and associated operations. EFCore.PG 10 now fully supports the `cube` type out-of-the-box, simply add an `NpgsqlCube` property to your entity type:
142+
143+
```c#
144+
public class Blog
145+
{
146+
...
147+
148+
public NpgsqlCube Cube { get; set; }
149+
}
150+
```
151+
152+
Most translations over the type are supported as well. Thanks to [@kirkbrauer](https://github.com/kirkbrauer) for contributing this feature!
153+
139154
## Other new features
140155

141156
* NodaTime `LocalDate.At()` and `LocalDate.AtMidnight()` are now translated.

conceptual/Npgsql/release-notes/10.0.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ GSSAPI session encryption is an alternative to SSL/TLS session encryption, where
1515

1616
`RequireAuth` is used to determine which authentication methods are allowed/required. For example, if you want to make sure that passwords aren't sent as cleartext or MD5, you can specify `RequireAuth=!Password,!MD5`. Or, if you want to make sure to always authenticate either via ScramSHA256 or GSS, then you can specify it as `RequireAuth=ScramSHA256,GSS`. To learn more, see PostgreSQL [docs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH).
1717

18+
## Support for the cube extension
19+
20+
PostgreSQL bundles the [`cube`](https://www.postgresql.org/docs/current/cube.html) extension, which provides a multi-dimensional cube data type and associated operations. Npgsql 10 now fully supports the `cube` type out-of-the-box:
21+
22+
```c#
23+
command.CommandText = """
24+
CREATE EXTENSION IF NOT EXISTS cube;
25+
CREATE TABLE data (my_cude CUBE);
26+
""";
27+
await command.ExecuteNonQueryAsync();
28+
29+
var cube = new NpgsqlCube([1.0, 2.0, 3.0], [4.0, 5.0, 6.0]);
30+
command.CommandText = "INSERT INTO data (my_cude) VALUES ($1)";
31+
command.Parameters.Add(new() { Value = cube });
32+
await command.ExecuteNonQueryAsync();
33+
34+
command.CommandText = "SELECT my_cude FROM data";
35+
var readCube = (NpgsqlCube)(await command.ExecuteScalarAsync())!;
36+
Console.WriteLine($"Read cube: {readCube}");
37+
```
38+
39+
Thanks to [@kirkbrauer](https://github.com/kirkbrauer) for contributing this feature!
40+
1841
## Various other changes
1942

2043
* OpenTelemetry tracing now also included by default for whenever a physical connection to database is open.

conceptual/Npgsql/types/basic.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ polygon | NpgsqlPolygon |
5151
line | NpgsqlLine |
5252
circle | NpgsqlCircle |
5353
box | NpgsqlBox |
54+
cube | NpgsqlCube<sup>5</sup> |
5455
hstore | Dictionary<string, string> |
5556
oid | uint |
5657
xid | uint |
@@ -74,6 +75,8 @@ array types | Array (of element type) |
7475

7576
<sup>4</sup> Prior to version 8.0, the default mapping for `cidr` was `ValueTuple<IPAddress, int>`.
7677

78+
<sup>5</sup> Introduced in Npgsql 10.0.0. Requires the PostgreSQL [`cube`](https://www.postgresql.org/docs/current/cube.html) extension.
79+
7780
## Write mappings
7881

7982
There are three rules that determine the PostgreSQL type sent for a parameter:
@@ -122,6 +125,7 @@ polygon | NpgsqlPolygon |
122125
line | NpgsqlLine | | Line |
123126
circle | NpgsqlCircle | | Circle |
124127
box | NpgsqlBox | | Box |
128+
cube | NpgsqlCube<sup>4</sup> | | Cube |
125129
hstore | IDictionary\<string, string\> | | Hstore |
126130
oid | | uint | Oid |
127131
xid | | uint | Xid |
@@ -140,6 +144,8 @@ array types | T[], List\<T\> |
140144

141145
<sup>3</sup>Types which can be read as `byte[]` can also be written as `ReadOnlyMemory<byte>` and `Stream`.
142146

147+
<sup>4</sup> Introduced in Npgsql 10.0.0. Requires the PostgreSQL [`cube`](https://www.postgresql.org/docs/current/cube.html) extension.
148+
143149
Notes when using Range and Array, bitwise-or NpgsqlDbType.Range or NpgsqlDbType.Array with the child type. For example, to construct the NpgsqlDbType for a `int4range`, write `NpgsqlDbType.Range | NpgsqlDbType.Integer`. To construct the NpgsqlDbType for an `int[]`, write `NpgsqlDbType.Array | NpgsqlDbType.Integer`.
144150

145151
For information about enums, [see the Enums and Composites page](enums_and_composites.md).

0 commit comments

Comments
 (0)