Skip to content

Commit

Permalink
Merge pull request #43 from StevenRasmussen/v9
Browse files Browse the repository at this point in the history
V9 release
  • Loading branch information
StevenRasmussen authored Nov 21, 2024
2 parents bb65717 + 5b22bd7 commit 44bdc59
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 41 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ await this.Db.RaceResult
// FROM [RaceResult] AS [r]
// WHERE DATEDIFF_BIG(SECOND, [r].[StartTime], '2019-07-01T00:00:00.0000000Z') >= CAST(100000 AS bigint)
```
* 9.0.0 (Nov 20, 2024)
* Release for EF Core 9
* 9.0.0-rc.1.24451.1 (Sept 27, 2024)
* Release candidate 1 for EF Core 9
* 8.0.1 (April 6, 2024)
* Added support for compiled models - [#39](/../../issues/39)
* 8.0.0 (November 18, 2023)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NodaTime" Version="3.1.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NodaTime" Version="3.2.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public abstract class BaseNodaTimeMemberTranslator : IMemberTranslator
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly Dictionary<string, string> _datePartMapping;
private readonly Type _declaringType;
private static List<bool> _argumentsPropagateNullability = new List<bool>
{
false,
false,
};

public BaseNodaTimeMemberTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory, [NotNull] Type declaringType, [NotNull] Dictionary<string, string> datePartMapping)
{
Expand All @@ -35,7 +40,7 @@ public SqlExpression Translate(SqlExpression instance, MemberInfo member, Type r
"DATEPART",
new[] { _sqlExpressionFactory.Fragment(datePart), instance },
false,
null,
_argumentsPropagateNullability,
returnType);
}
else if (member.Name == nameof(LocalDateTime.Date) && returnType == typeof(LocalDate))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ public abstract class BaseNodaTimeMethodCallTranslator : IMethodCallTranslator
private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffMapping;
private readonly Dictionary<MethodInfo, string> _methodInfoDateDiffBigMapping;

private static List<bool> _2argumentsPropagateNullability = new List<bool>
{
false,
false,
};

private static List<bool> _3argumentsPropagateNullability = new List<bool>
{
false,
false,
false,
};

public BaseNodaTimeMethodCallTranslator(
ISqlExpressionFactory sqlExpressionFactory,
Dictionary<MethodInfo, string> methodInfoDateAddMapping,
Expand All @@ -41,17 +54,17 @@ public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadO
|| (sqlConstant.Value is long && ((long)sqlConstant.Value >= int.MaxValue || (long)sqlConstant.Value <= int.MinValue)))
? null
: _sqlExpressionFactory.Function(
"DATEADD",
new[]
name: "DATEADD",
arguments: new[]
{
_sqlExpressionFactory.Fragment(dateAddPart),
_sqlExpressionFactory.Convert(arguments[0], typeof(int)),
instance
},
false,
null,
instance.Type,
instance.TypeMapping);
nullable: false,
argumentsPropagateNullability: _3argumentsPropagateNullability,
returnType: instance.Type,
typeMapping: instance.TypeMapping);
}
else if (_methodInfoDateAddExtensionMapping != null && _methodInfoDateAddExtensionMapping.TryGetValue(method, out var dateAddExtensionPart))
{
Expand All @@ -60,31 +73,31 @@ public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadO
|| (sqlConstant.Value is long && ((long)sqlConstant.Value >= int.MaxValue || (long)sqlConstant.Value <= int.MinValue)))
? null
: _sqlExpressionFactory.Function(
"DATEADD",
new[]
name: "DATEADD",
arguments: new[]
{
_sqlExpressionFactory.Fragment(dateAddExtensionPart),
_sqlExpressionFactory.Convert(arguments[1], typeof(int)),
arguments[0]
},
false,
null,
arguments[0].Type,
arguments[0].TypeMapping);
nullable: false,
argumentsPropagateNullability: _3argumentsPropagateNullability,
returnType: arguments[0].Type,
typeMapping: arguments[0].TypeMapping);
}
else if (_methodInfoDatePartExtensionMapping != null && _methodInfoDatePartExtensionMapping.TryGetValue(method, out var datePart))
{
return _sqlExpressionFactory.Function(
"DATEPART",
new[]
name: "DATEPART",
arguments: new[]
{
_sqlExpressionFactory.Fragment(datePart),
arguments[0]
},
false,
null,
method.ReturnType,
null);
nullable: false,
argumentsPropagateNullability: _2argumentsPropagateNullability,
returnType: method.ReturnType,
typeMapping: null);
}
else if (_methodInfoDateDiffMapping != null && _methodInfoDateDiffMapping.TryGetValue(method, out var dateDiffDatePart))
{
Expand All @@ -96,12 +109,12 @@ public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadO
endDate = _sqlExpressionFactory.ApplyTypeMapping(endDate, typeMapping);

return _sqlExpressionFactory.Function(
"DATEDIFF",
new[] { _sqlExpressionFactory.Fragment(dateDiffDatePart), startDate, endDate },
false,
null,
method.ReturnType,
null);
name: "DATEDIFF",
arguments: new[] { _sqlExpressionFactory.Fragment(dateDiffDatePart), startDate, endDate },
nullable: false,
argumentsPropagateNullability: _3argumentsPropagateNullability,
returnType: method.ReturnType,
typeMapping: null);
}
else if (_methodInfoDateDiffBigMapping != null && _methodInfoDateDiffBigMapping.TryGetValue(method, out var dateDiffBigDatePart))
{
Expand All @@ -113,12 +126,12 @@ public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadO
endDate = _sqlExpressionFactory.ApplyTypeMapping(endDate, typeMapping);

return _sqlExpressionFactory.Function(
"DATEDIFF_BIG",
new[] { _sqlExpressionFactory.Fragment(dateDiffBigDatePart), startDate, endDate },
false,
null,
method.ReturnType,
null);
name: "DATEDIFF_BIG",
arguments: new[] { _sqlExpressionFactory.Fragment(dateDiffBigDatePart), startDate, endDate },
nullable: false,
argumentsPropagateNullability: _3argumentsPropagateNullability,
returnType: method.ReturnType,
typeMapping: null);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<PackageProjectUrl>https://github.com/StevenRasmussen/EFCore.SqlServer.NodaTime</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Entity Framework Core;entity-framework-core;EF;Data;O/RM;EntityFrameworkCore;EFCore;Noda;NodaTime;Noda Time</PackageTags>
<Version>8.0.1</Version>
<Version>9.0.0</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="NodaTime" Version="3.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="NodaTime" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 44bdc59

Please sign in to comment.