Skip to content

Commit d52c907

Browse files
Updated the ReadMe to point to ZZZ website.
1 parent 6b151d4 commit d52c907

File tree

1 file changed

+2
-246
lines changed

1 file changed

+2
-246
lines changed

README.md

Lines changed: 2 additions & 246 deletions
Original file line numberDiff line numberDiff line change
@@ -1,216 +1,11 @@
11
![.NET Core](https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime/workflows/.NET%20Core/badge.svg?branch=master)
22
[![NuGet version (EFCore.SqlServer.NodaTime)](https://img.shields.io/nuget/v/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.svg)](https://www.nuget.org/packages/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime/)
3-
[Version History](#version-history)
43

5-
# EFCore.SqlServer.NodaTime
4+
# EntityFrameworkCore.SqlServer.NodaTime
65

76
Adds native support to EntityFrameworkCore for SQL Server for the [NodaTime](https://nodatime.org/) types.
87

9-
When modelling, usage of the following NodaTime types are supported:
10-
* Instant
11-
* OffsetDateTime
12-
* LocalDateTime
13-
* LocalDate
14-
* LocalTime
15-
* Duration (stored as `time` in SQL Server which limits this type to < 24 hours)
16-
17-
When querying, standard operators are supported as well as a range of additional mappings from NodaTime properties/function to their SQL Server equivalents.
18-
19-
## Unit Tests
20-
All types and their methods have unit tests written to verify that the SQL is translated as expected. See individual tests for more information.
21-
22-
**Note:** To run the unit tests for the first time, you will need to uncomment the lines [here](https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime/blob/017f19d68ac12e0ff2ce3ba34f60f1edd42badfe/src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DatabaseTestFixture.cs#L20-L21). This ensures that the test DB is created locally.
23-
24-
## Usage
25-
To use, simply install the NuGet package:
26-
```shell
27-
Install-Package SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime
28-
```
29-
30-
**Note:** Versioning follows the [major.minor] of EF Core so that it is easy to know which version to install. Ie, if you are using EF Core v5.x then you would install v5.x of this package. Build and revision numbers are not guaranteed to follow the same numbers.
31-
32-
Then call the `UseNodaTime()` method as part of your SqlServer configuration during the `UseSqlServer` method call:
33-
```csharp
34-
using Microsoft.EntityFrameworkCore;
35-
36-
options.UseSqlServer("your DB Connection",
37-
x => x.UseNodaTime());
38-
```
39-
40-
## Reverse Engineering (Scaffolding)
41-
Support for [reverse engineering](https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli) has been added starting in v5.0.2.
42-
43-
The SQL Server types map as follows:
44-
* `smalldatetime` -> `Instant`
45-
* `datetime` -> `Instant`
46-
* `datetime2` -> `Instant`
47-
* `date` -> `LocalDate`
48-
* `time` -> `LocalTime`
49-
* `datetimeoffset` -> `OffsetDateTime`
50-
51-
## Additional property / function mappings
52-
53-
### DATEADD Support
54-
The SQL `DATEADD` function is supported for the following types:
55-
* Instant (extension methods)
56-
* OffsetDateTime (native and some extension methods)
57-
* LocalDateTime (native and some extension methods)
58-
* LocalDate (native and some extension methods)
59-
* LocalTime (native and some extension methods)
60-
* Duration (native and some extension methods)
61-
62-
**Note**: Please add a using statement in order to use the extension methods:
63-
```csharp
64-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
65-
```
66-
67-
#### Supported Methods
68-
* PlusYears
69-
* PlusMonths
70-
* PlusDays
71-
* PlusHours
72-
* PlusMinutes
73-
* PlusSeconds
74-
* PlusMilliseconds
75-
76-
```csharp
77-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
78-
79-
// PlusYears
80-
await this.Db.RaceResult
81-
.Where(r => r.StartTime.PlusYears(1) >= Instant.FromUtc(2019, 7, 1, 1, 0))
82-
.ToListAsync();
83-
84-
// Translates to:
85-
// SELECT [r].[Id], [r].[EndTime], [r].[StartTime], [r].[StartTimeOffset]
86-
// FROM [RaceResult] AS [r] WHERE DATEADD(year, CAST(1 AS int), [r].[StartTime]) >= '2019-07-01T01:00:00.0000000Z'
87-
```
88-
89-
### DATEPART Support
90-
The SQL `DATEPART` function is supported for the following types:
91-
* Instant (extension methods)
92-
* OffsetDateTime (native and some extension methods)
93-
* LocalDateTime (native and some extension methods)
94-
* LocalDate (native and some extension methods)
95-
* LocalTime (native and some extension methods)
96-
* Duration (native and some extension methods)
97-
98-
**Note**: Please add a using statement in order to use the extension methods:
99-
```csharp
100-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
101-
```
102-
103-
#### Supported Parts
104-
* Year
105-
* Quarter
106-
* Month
107-
* DayOfYear
108-
* Day
109-
* Week
110-
* WeekDay
111-
* Hour
112-
* Minute
113-
* Second
114-
* Millisecond
115-
* Microsecond
116-
* Nanosecond
117-
* TzOffset
118-
* IsoWeek
119-
120-
```csharp
121-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
122-
123-
// Compare the 'Year' DatePart
124-
await this.Db.RaceResult
125-
.Where(r => r.StartTime.Year() == 2019)
126-
.ToListAsync();
127-
128-
// Translates to:
129-
// SELECT [r].[Id], [r].[EndTime], [r].[StartTime], [r].[StartTimeOffset]
130-
// FROM [RaceResult] AS [r] WHERE DATEPART(year, [r].[StartTime]) = 2019
131-
```
132-
133-
### DATEDIFF Support
134-
The SQL `DATEDIFF` function is supported for the following types:
135-
* Instant (extension methods)
136-
* OffsetDateTime (extension methods)
137-
* LocalDateTime (extension methods)
138-
* LocalDate (extension methods)
139-
* LocalTime (extension methods)
140-
* Duration (extension methods)
141-
142-
**Note**: Please add a using statement in order to use the extension methods:
143-
```csharp
144-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
145-
```
146-
147-
#### Supported Parts
148-
* Year
149-
* Quarter
150-
* Month
151-
* DayOfYear
152-
* Day
153-
* Week
154-
* WeekDay
155-
* Hour
156-
* Minute
157-
* Second
158-
* Millisecond
159-
* Microsecond
160-
* Nanosecond
161-
* TzOffset
162-
* IsoWeek
163-
164-
```csharp
165-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
166-
167-
// DateDiff based on 'day'
168-
DbFunctions dbFunctions = null;
169-
170-
await this.Db.Race
171-
.Where(r => dbFunctions.DateDiffDay(r.Date, new LocalDate(2020, 1, 1)) >= 200)
172-
.ToListAsync();
173-
174-
// Translates to:
175-
// SELECT [r].[Id], [r].[Date], [r].[ScheduledDuration], [r].[ScheduledStart], [r].[ScheduledStartTime]
176-
// FROM [Race] AS [r]
177-
// WHERE DATEDIFF(DAY, [r].[Date], '2020-01-01') >= 200
178-
```
179-
180-
### DATEDIFF_BIG Support
181-
The SQL `DATEDIFF_BIG` function is supported for the following types:
182-
* Instant (extension methods)
183-
* OffsetDateTime (extension methods)
184-
* LocalDateTime (extension methods)
185-
* LocalTime (extension methods)
186-
* Duration (extension methods)
187-
188-
**Note**: Please add a using statement in order to use the extension methods:
189-
```csharp
190-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
191-
```
192-
193-
#### Supported Parts
194-
* Second
195-
* Millisecond
196-
* Microsecond
197-
* Nanosecond
198-
199-
```csharp
200-
using Microsoft.EntityFrameworkCore.SqlServer.NodaTime.Extensions;
201-
202-
// DateDiffBig based on 'second'
203-
DbFunctions dbFunctions = null;
204-
205-
await this.Db.RaceResult
206-
.Where(r => dbFunctions.DateDiffBigSecond(r.StartTime, Instant.FromUtc(2019, 7, 1, 0, 0)) >= 100000)
207-
.ToListAsync();
208-
209-
// Translates to:
210-
// SELECT [r].[Id], [r].[EndTime], [r].[OffsetFromWinner], [r].[StartTime], [r].[StartTimeOffset]
211-
// FROM [RaceResult] AS [r]
212-
// WHERE DATEDIFF_BIG(SECOND, [r].[StartTime], '2019-07-01T00:00:00.0000000Z') >= CAST(100000 AS bigint)
213-
```
8+
Read more at [Learn Entity Framework Core](https://www.learnentityframeworkcore.com/extensions/entityframeworkcore-sqlserver-nodatime)
2149

21510
## Sponsors
21611

@@ -220,42 +15,3 @@ await this.Db.RaceResult
22015

22116
[![Dapper Plus](https://raw.githubusercontent.com/StevenRasmussen/EFCore.SqlServer.NodaTime/master/dapper-plus-sponsor.png)](https://dapper-plus.net/bulk-insert)
22217

223-
## Version History
224-
225-
* 9.1.0 (Mar 14, 2025)
226-
* Added support for Azure SQL DB's and the `AzureSqlDbContextOptionsBuilder`
227-
* 9.0.0 (Nov 20, 2024)
228-
* Release for EF Core 9
229-
* 9.0.0-rc.1.24451.1 (Sept 27, 2024)
230-
* Release candidate 1 for EF Core 9
231-
* 8.0.1 (April 6, 2024)
232-
* Added support for compiled models - [#39](/../../issues/39)
233-
* 8.0.0 (November 18, 2023)
234-
* Release for EF Core 8
235-
* 8.0.0-rc.1.23419.6 (September 15, 2023)
236-
* Release candidate 1 for EF Core 8
237-
* 7.1.0 (August 12, 2023)
238-
* Added support for `LocalDateTime.Date` property - [#35](/../../issues/35)
239-
* Added support for `OffsetDateTime.Date` property
240-
* 7.0.0 (November 9, 2022)
241-
* Initial release supporting EF Core 7.0.0
242-
* 7.0.0-rc.1.22426.7 (September 25, 2022)
243-
* Release candidate for EF Core 7
244-
* 6.0.1
245-
* Fixed an issue where an `ArgumentNullException` would throw if you called `UseInternalServiceProvider` - [#27](/../../issues/27)
246-
* 6.0.0
247-
* Support for .Net 6 - [#23](/../../issues/23)
248-
* 5.0.3
249-
* Fixed an issue where `DateTime` queries failed in some instances - [#25](/../../issues/25)
250-
* 5.0.2
251-
* Added design time support - [#16](/../../issues/16)
252-
* 5.0.1
253-
* Fix SqlDateTime overflow - [#13](/../../issues/13)
254-
* 5.0.0
255-
* Support for .Net 5
256-
* 3.1.2
257-
* Fixed an issue where `DateTime` queries failed in some instances - [#25](/../../issues/25)
258-
* 3.1.1
259-
* Fix SqlDateTime overflow - [#13](/../../issues/13)
260-
* 3.1.0
261-
* Sync version number with .Net Core 3.1.0

0 commit comments

Comments
 (0)