SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime
1.2.0
See the version list below for details.
dotnet add package SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime --version 1.2.0
NuGet\Install-Package SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime -Version 1.2.0
<PackageReference Include="SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime" Version="1.2.0" />
paket add SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime --version 1.2.0
#r "nuget: SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime, 1.2.0"
// Install SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime as a Cake Addin #addin nuget:?package=SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime&version=1.2.0 // Install SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime as a Cake Tool #tool nuget:?package=SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime&version=1.2.0
EFCore.NodaTime
Adds native support to EntityFrameworkCore for SQL Server for the NodaTime types.
The following types are supported:
- Instant
- OffsetDateTime
- LocalDateTime
- LocalDate
- LocalTime
- Duration
Unit Tests
All types and their methods have unit tests written to verify that the SQL is translated as expected. See individual tests for more information.
Usage
To use, simply install the NuGet package:
Install-Package SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime
Then call the UseNodaTime()
method as part of your SqlServer configuration during the UseSqlServer
method call:
Using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
options.UseSqlServer("your DB Connection",
x => x.UseNodaTime());
DATEADD Support
The SQL DATEADD
function is supported for the following types:
- Instant (extension methods)
- OffsetDateTime (native and some extension methods)
- LocalDateTime (native and some extension methods)
- LocalDate (native and some extension methods)
- LocalTime (native and some extension methods)
- Duration (native and some extension methods)
Note: Please add a using statement in order to use the extension methods:
Using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
Supported Methods
- PlusYears
- PlusMonths
- PlusDays
- PlusHours
- PlusMinutes
- PlusSeconds
- PlusMilliseconds
Using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
// PlusYears
await this.Db.RaceResult
.Where(r => r.StartTime.PlusYears(1) >= Instant.FromUtc(2019, 7, 1, 1, 0))
.ToListAsync();
// Translates to:
// SELECT [r].[Id], [r].[EndTime], [r].[StartTime], [r].[StartTimeOffset]
// FROM [RaceResult] AS [r] WHERE DATEADD(year, CAST(1 AS int), [r].[StartTime]) >= '2019-07-01T01:00:00.0000000Z'
DATEPART Support
The SQL DATEPART
function is supported for the following types:
- Instant (extension methods)
- OffsetDateTime (native and some extension methods)
- LocalDateTime (native and some extension methods)
- LocalDate (native and some extension methods)
- LocalTime (native and some extension methods)
- Duration (native and some extension methods)
Note: Please add a using statement in order to use the extension methods:
Using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
Supported Methods
- Year
- Quarter
- Month
- DayOfYear
- Day
- Week
- WeekDay
- Hour
- Minute
- Second
- Millisecond
- Microsecond
- Nanosecond
- TzOffset
- IsoWeek
Using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
// Compare the 'Year' DatePart
await this.Db.RaceResult
.Where(r => r.StartTime.Year() == 2019)
.ToListAsync();
// Translates to:
// SELECT [r].[Id], [r].[EndTime], [r].[StartTime], [r].[StartTimeOffset]
// FROM [RaceResult] AS [r] WHERE DATEPART(year, [r].[StartTime]) = 2019
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- JetBrains.Annotations (>= 2019.1.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 3.1.2)
- NodaTime (>= 2.4.7)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime:
Package | Downloads |
---|---|
EasyDesk.CleanArchitecture.Dal.SqlServer
Utilities for the SqlServer data access layer of the clean architecture as seen by EasyDesk. |
|
SiamOutlet.IFP.Core
Core Library for IFP |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime:
Repository | Stars |
---|---|
ErikEJ/EFCorePowerTools
Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
|
|
yangzhongke/Zack.EFCore.Batch
Deleting or Updating multiple records from a LINQ Query in a SQL statement without loading entities
|
Version | Downloads | Last updated |
---|---|---|
9.0.0-rc.1.24451.1 | 827 | 9/27/2024 |
8.0.1 | 178,824 | 4/6/2024 |
8.0.0 | 120,971 | 11/18/2023 |
7.1.0 | 148,696 | 8/12/2023 |
7.0.0 | 132,362 | 11/9/2022 |
6.0.1 | 299,674 | 3/20/2022 |
6.0.0 | 173,864 | 11/8/2021 |
5.0.3 | 10,815 | 11/9/2021 |
5.0.2 | 32,696 | 4/14/2021 |
5.0.1 | 29,885 | 11/28/2020 |
5.0.0 | 846 | 11/10/2020 |
3.1.2 | 10,139 | 11/9/2021 |
3.1.1 | 14,561 | 11/28/2020 |
3.1.0 | 1,611 | 11/10/2020 |
1.3.3 | 781 | 10/20/2020 |
1.3.2 | 1,287 | 9/25/2020 |
1.3.1 | 1,459 | 9/7/2020 |
1.3.0 | 4,167 | 3/19/2020 |
1.2.0 | 815 | 3/3/2020 |