Skip to content
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
7 changes: 3 additions & 4 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
include-prerelease: true
- name: Build with dotnet
run: dotnet build "./src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.sln" --configuration Release
# name: Execute Tests
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,7 @@ healthchecksdb
MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
.ionide/

# Claude Code local config
.claude/
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,42 @@

Assert.Equal(6, raceResults.Count);
}

[Fact]
public async Task DateTime_UtcNow_Test()
{
var raceResults = await this.Db.Race.Select(r => new { NowUtc = DateTime.UtcNow }).ToListAsync();

Assert.Equal(
condense(@$"SELECT GETUTCDATE() AS [NowUtc] FROM [Race] AS [r]"),
condense(this.Db.Sql));

Assert.Equal(12, raceResults.Count);
}

[Fact]
public async Task DateTime_UtcNow_Compared_Test()
{
var raceResults = await this.Db.Race.Where(r => r.DateTimeDate.Date >= DateTime.UtcNow).ToListAsync();

Assert.Equal(
condense(@$"{RaceSelectStatement} WHERE CONVERT(date, [r].[DateTimeDate]) >= GETUTCDATE()"),
condense(this.Db.Sql));

Assert.Equal(0, raceResults.Count);

Check warning on line 47 in src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DateTimeQueryTests.cs

View workflow job for this annotation

GitHub Actions / build

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 47 in src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DateTimeQueryTests.cs

View workflow job for this annotation

GitHub Actions / build

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
}

[Fact]
public async Task DateTime_UtcNow_And_Input_Parameter_Test()
{
var dt = new DateTime(2019, 7, 1);
var raceResults = await this.Db.Race.Where(r => dt >= DateTime.UtcNow).ToListAsync();

Assert.Equal(
condense(@$"{RaceSelectStatement} WHERE @dt >= GETUTCDATE()"),
condense(this.Db.Sql));

Assert.Equal(0, raceResults.Count);

Check warning on line 60 in src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DateTimeQueryTests.cs

View workflow job for this annotation

GitHub Actions / build

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 60 in src/SimplerSoftware.EntityFrameworkCore.SqlServer.NodaTime.Tests/DateTimeQueryTests.cs

View workflow job for this annotation

GitHub Actions / build

Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RepositoryUrl>https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Entity Framework Core;entity-framework-core;EF;Data;O/RM;EntityFrameworkCore;EFCore;Noda;NodaTime;Noda Time</PackageTags>
<Version>10.0.0</Version>
<Version>10.0.1</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ public RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInf
{
if (StoreTypeMappings.TryGetValue(storeTypeName, out var mappings))
{
// When clrType is null, defer to EF Core's default mapping source: our store
// types (datetime, datetime2, etc.) all have non-NodaTime defaults that EF
// can supply. Returning a NodaTime mapping here pollutes plain DateTime
// expressions like DateTime.UtcNow with InstantValueConverter.
if (clrType == null)
return mappings[0];
return null;

foreach (var m in mappings)
if (m.ClrType == clrType)
Expand All @@ -73,7 +77,7 @@ public RelationalTypeMapping FindMapping(in RelationalTypeMappingInfo mappingInf
if (StoreTypeMappings.TryGetValue(storeTypeNameBase!, out mappings))
{
if (clrType == null)
return mappings[0].Clone(mappingInfo);
return null;

foreach (var m in mappings)
if (m.ClrType == clrType)
Expand Down
Loading