Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EF Core 6.0 release and breaking change notes #116

Merged
merged 3 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions conceptual/EFCore.PG/mapping/nodatime.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class Post
var recentPosts = context.Posts.Where(p => p.CreationTime > someInstant);
```

## Member translation
## Operation translation

Currently, the EF Core provider knows how to translate the most date/time component members of NodaTime's `LocalDateTime`, `LocalDate`, `LocalTime` and `Period`. In other words, the following query will be translated to SQL and evaluated server-side:
The provider knows how to translate many members and methods on mapped NodaTime types. For example, the following query will be translated to SQL and evaluated server-side:

```c#
// Get all events which occurred on a Monday
Expand All @@ -47,4 +47,49 @@ var mondayEvents = context.Events.Where(p => p.SomeDate.DayOfWeek == DayOfWeek.M
var oldEvents = context.Events.Where(p => p.SomeDate.Year < 2000);
```

Note that the plugin is far from covering all translations. If a translation you need is missing, please open an issue to request for it.
Following is the list of supported NodaTime translations; If an operation you need is missing, please open an issue to request for it.

> [!NOTE]
> Most translations on ZonedDateTime and Period were added in version 6.0

.NET | SQL | Notes
------------------------------------------------------- |------------------------------------------------------------------------- | ---
SystemClock.Instance.GetCurrentInstant() | [now()](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Date | [date_trunc('day', timestamp)](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Second (also LocalTime, ZonedDateTime) | [date_part('second', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Minute (also LocalTime, ZonedDateTime) | [date_part('minute', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Hour (also LocalTime, ZonedDateTime) | [date_part('hour', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Day, (also LocalDate, ZonedDateTime) | [date_part('day', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Month (also LocalDate, ZonedDateTime) | [date_part('month', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.Year (also LocalDate, ZonedDateTime) | [date_part('year', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.DayOfWeek (also LocalDate, ZonedDateTime) | [floor(date_part('dow', timestamp))::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
LocalDateTime.DayOfYear (also LocalDate, ZonedDateTime) | [date_part('doy', timestamp)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Seconds (also Duration) | [date_part('second', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Minutes (also Duration) | [date_part('minute', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Hours (also Duration) | [date_part('hour', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Days (also Duration) | [date_part('day', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Months | [date_part('month', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.Years | [date_part('year', interval)::INT](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromSeconds | [make_interval(seconds => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromMinutes | [make_interval(minutes => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromHours | [make_interval(hours => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromDays | [make_interval(days => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromWeeks | [make_interval(weeks => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromMonths | [make_interval(months => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Period.FromYears | [make_interval(years => int)](https://www.postgresql.org/docs/current/functions-datetime.html)
Duration.TotalMilliseconds | [date_part('epoch', interval) / 0.001](https://www.postgresql.org/docs/current/functions-datetime.html)
Duration.TotalSeconds | [date_part('epoch', interval)](https://www.postgresql.org/docs/current/functions-datetime.html)
Duration.TotalMinutes | [date_part('epoch', interval) / 60.0](https://www.postgresql.org/docs/current/functions-datetime.html)
Duration.TotalDays | [date_part('epoch', interval) / 86400.0](https://www.postgresql.org/docs/current/functions-datetime.html)
Duration.TotalHours | [date_part('epoch', interval) / 3600.0](https://www.postgresql.org/docs/current/functions-datetime.html)
ZonedDateTime.LocalDateTime | [timestamptz AT TIME ZONE 'UTC'](https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-ZONECONVERT) | Added in 6.0
DateInterval.Length | [upper(daterange) - lower(daterange)](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.Start | [lower(daterange)](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.End | [upper(daterange) - INTERVAL 'P1D'](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.Contains(LocalDate) | [daterange @> date](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.Contains(DateInterval) | [daterange @> daterange](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.Intersection(DateInterval) | [daterange * daterange](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
DateInterval.Union(DateInterval) | [daterange + daterange](https://www.postgresql.org/docs/current/functions-range.html) | Added in 6.0
Instant.InUtc | No PG operation (.NET-side conversion from Instant to ZonedDateTime only) | Added in 6.0

In addition to the above, most arithmetic operators are also translated (e.g. LocalDate + Period).
11 changes: 6 additions & 5 deletions conceptual/EFCore.PG/mapping/nts.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ The following table lists NetTopologySuite operations which are translated to Po

Note that the plugin is far from covering all spatial operations. If an operation you need is missing, please open an issue to request for it.

.NET | SQL
---------------------------------------------------------------- |-----
.NET | SQL | Notes
---------------------------------------------------------------- |------------------------------------------------------------------------------------- | -----
geom.Area() | [ST_Area(geom)](https://postgis.net/docs/ST_Area.html)
geom.AsBinary() | [ST_AsBinary(geom)](https://postgis.net/docs/ST_AsBinary.html)
geom.AsText() | [ST_AsText(geom)](https://postgis.net/docs/ST_AsText.html)
Expand All @@ -104,15 +104,16 @@ geom1.Difference(geom2) | [ST_Differenc
geom1.Dimension | [ST_Dimension(geom1)](https://postgis.net/docs/ST_Dimension.html)
geom1.Disjoint(geom2) | [ST_Disjoint(geom1, geom2)](https://postgis.net/docs/ST_Disjoint.html)
geom1.Distance(geom2) | [ST_Distance(geom1, geom2)](https://postgis.net/docs/ST_Distance.html)
EF.Functions.DistanceKnn(geom1, geom2) (v6) | [geom1 <-> geom2](https://postgis.net/docs/geometry_distance_knn.html)
EF.Functions.Distance(geom1, geom2, useSpheriod) (v6) | [ST_Distance(geom1, geom2, useSpheriod)](https://postgis.net/docs/ST_Distance.html)
EF.Functions.DistanceKnn(geom1, geom2) | [geom1 <-> geom2](https://postgis.net/docs/geometry_distance_knn.html) | Added in 6.0
EF.Functions.Distance(geom1, geom2, useSpheriod) | [ST_Distance(geom1, geom2, useSpheriod)](https://postgis.net/docs/ST_Distance.html) | Added in 6.0
geom1.Envelope | [ST_Envelope(geom1)](https://postgis.net/docs/ST_Envelope.html)
geom1.ExactEquals(geom2) | [ST_OrderingEquals(geom1, geom2)](https://postgis.net/docs/ST_OrderingEquals.html)
lineString.EndPoint | [ST_EndPoint(lineString)](https://postgis.net/docs/ST_EndPoint.html)
polygon.ExteriorRing | [ST_ExteriorRing(polygon)](https://postgis.net/docs/ST_ExteriorRing.html)
geom1.Equals(geom2) | [geom1 = geom2](https://postgis.net/docs/ST_Geometry_EQ.html)
geom1.Polygon.EqualsExact(geom2) | [geom1 = geom2](https://postgis.net/docs/ST_Geometry_EQ.html)
geom1.EqualsTopologically(geom2) | [ST_Equals(geom1, geom2)](https://postgis.net/docs/ST_Equals.html)
EF.Functions.Force2D | [ST_Force2D(geom)](https://postgis.net/docs/ST_Force2D.html) | Added in 6.0
geom.GeometryType | [GeometryType(geom)](https://postgis.net/docs/GeometryType.html)
geomCollection.GetGeometryN(i) | [ST_GeometryN(geomCollection, i)](https://postgis.net/docs/ST_GeometryN.html)
linestring.GetPointN(i) | [ST_PointN(linestring, i)](https://postgis.net/docs/ST_PointN.html)
Expand All @@ -123,7 +124,7 @@ lineString.IsClosed() | [ST_IsClosed(
geomCollection.IsEmpty() | [ST_IsEmpty(geomCollection)](https://postgis.net/docs/ST_IsEmpty.html)
linestring.IsRing | [ST_IsRing(linestring)](https://postgis.net/docs/ST_IsRing.html)
geom.IsWithinDistance(geom2,d) | [ST_DWithin(geom1, geom2, d)](https://postgis.net/docs/ST_DWithin.html)
EF.Functions.IsWithinDistance(geom1, geom2, d, useSpheriod) (v6) | [ST_DWithin(geom1, geom2, d, useSpheriod)](https://postgis.net/docs/ST_DWithin.html)
EF.Functions.IsWithinDistance(geom1, geom2, d, useSpheriod) | [ST_DWithin(geom1, geom2, d, useSpheriod)](https://postgis.net/docs/ST_DWithin.html) | Added in 6.0
geom.IsSimple() | [ST_IsSimple(geom)](https://postgis.net/docs/ST_IsSimple.html)
geom.IsValid() | [ST_IsValid(geom)](https://postgis.net/docs/ST_IsValid.html)
lineString.Length | [ST_Length(lineString)](https://postgis.net/docs/ST_Length.html)
Expand Down
Loading