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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.x
dotnet-version: 10.x

- name: Set Variables
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.x
dotnet-version: 10.x

- name: Set Variables
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>AutoMapper.AspNet.OData</RootNamespace>
<PackageId>AutoMapper.AspNetCore.OData.EF6</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting AutoMapper v15 (EF Core only).</PackageReleaseNotes>
<PackageReleaseNotes>Supporting AutoMapper v16 (EF Core only).</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand Down Expand Up @@ -62,7 +62,7 @@
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[6.0.4,7.0.0)" />
<PackageReference Include="EntityFramework" Version="6.5.1" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.4.1" />
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<RootNamespace>AutoMapper.AspNet.OData</RootNamespace>
<PackageId>AutoMapper.AspNetCore.OData.EFCore</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting AutoMapper v15 (EF Core only).</PackageReleaseNotes>
<PackageReleaseNotes>Supporting AutoMapper v16 (EF Core only).</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand All @@ -30,9 +30,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[9.0.0,10.0.0)" />
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[10.0.0,11.0.0)" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.1.1" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.4.1" />
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand All @@ -47,6 +47,10 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net9.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
68 changes: 49 additions & 19 deletions AutoMapper.AspNetCore.OData.EFCore/FilterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ private IExpressionPart GetIsOdFilterPart(List<QueryNode> arguments)
if (!(arguments[0] is SingleValueNode sourceNode))
throw new ArgumentException("Expected SingleValueNode for source node.");

if (!(arguments[1] is ConstantNode typeNode))
throw new ArgumentException("Expected ConstantNode for type node.");
if (arguments[1] is ConstantNode typeNode)
return IsOf(GetCastType(typeNode));

return IsOf(GetCastType(typeNode));
if (arguments[1] is SingleResourceCastNode singleResourceCastNode)
return IsOf(GetCastType(singleResourceCastNode));

throw new ArgumentException("Expected ConstantNode or SingleResourceCastNode for type node.");

IExpressionPart IsOf(Type conversionType)
=> new IsOfOperator(GetFilterPart(sourceNode), conversionType);
Expand All @@ -255,14 +258,25 @@ private IExpressionPart GetCastResourceFilterPart(List<QueryNode> arguments)
if (!(arguments[0] is SingleValueNode sourceNode))
throw new ArgumentException("Expected SingleValueNode for source node.");

if (!(arguments[1] is ConstantNode typeNode))
throw new ArgumentException("Expected ConstantNode for type node.");
if (arguments[1] is ConstantNode typeNode)
{
return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(typeNode)
);
}

return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(typeNode)
);
if (arguments[1] is SingleResourceCastNode singleResourceCastNode)
{
return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(singleResourceCastNode)
);
}

throw new ArgumentException("Expected ConstantNode or SingleResourceCastNode for type node.");

IExpressionPart Convert(Type operandType, Type conversionType)
{
Expand Down Expand Up @@ -291,23 +305,36 @@ private IExpressionPart GetCastFilterPart(List<QueryNode> arguments)
if (!(arguments[0] is SingleValueNode sourceNode))
throw new ArgumentException("Expected SingleValueNode for source node.");

if (!(arguments[1] is ConstantNode typeNode))
throw new ArgumentException("Expected ConstantNode for type node.");
if (arguments[1] is ConstantNode typeNode)
{
return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(typeNode),
typeNode.TypeReference
);
}

return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(typeNode)
);
if (arguments[1] is SingleResourceCastNode singleResourceCastNode)
{
return Convert
(
GetClrType(sourceNode.TypeReference),
GetCastType(singleResourceCastNode),
singleResourceCastNode.TypeReference
);
}

IExpressionPart Convert(Type operandType, Type conversionType)
throw new ArgumentException("Expected ConstantNode or SingleResourceCastNode for type node.");

IExpressionPart Convert(Type operandType, Type conversionType, IEdmTypeReference edmTypeReference)
{
if (OperandIsNullConstant(sourceNode) || operandType == conversionType)
return GetFilterPart(sourceNode);

if (ShouldConvertTypes(operandType, conversionType, sourceNode))
{
if ((!typeNode.TypeReference.IsPrimitive() && !typeNode.TypeReference.IsEnum())
if ((!edmTypeReference.IsPrimitive() && !edmTypeReference.IsEnum())
|| (!operandType.IsLiteralType() && !operandType.ToNullableUnderlyingType().IsEnum))
return new ConstantOperator(null);

Expand Down Expand Up @@ -345,6 +372,9 @@ IExpressionPart Convert(Type operandType, Type conversionType)
private Type GetCastType(ConstantNode constantNode)
=> TypeExtensions.GetClrType((string)constantNode.Value, false, typesCache);

private Type GetCastType(SingleResourceCastNode singleResourceCastNode)
=> TypeExtensions.GetClrType(singleResourceCastNode.TypeReference, typesCache);

private IExpressionPart GetCustomMehodFilterPart(string functionName, SingleValueNode[] arguments)
{
MethodInfo methodInfo = CustomMethodCache.GetCachedCustomMethod(functionName, arguments.Select(p => GetClrType(p.TypeReference)));
Expand Down
4 changes: 2 additions & 2 deletions AutoMapper.Extensions.OData.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
# Visual Studio Version 18
VisualStudioVersion = 18.1.11312.151 d18.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMapper.AspNetCore.OData.EFCore", "AutoMapper.AspNetCore.OData.EFCore\AutoMapper.AspNetCore.OData.EFCore.csproj", "{8E4C661E-C58A-4515-9CBF-F58D9D6E941D}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>net10.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>net10.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down
14 changes: 5 additions & 9 deletions DAL.EFCore/DAL.EFCore.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
</ItemGroup>
Expand All @@ -20,4 +12,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFrameworks>net10.0</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
Loading