Skip to content

Commit

Permalink
Mapping EntityFrameworkCore version to framework version. (#121)
Browse files Browse the repository at this point in the history
* Mapping EntityFrameworkCore version to framework version.

* sdk

* net6.0 the test projects.

* Really net6.0 the tests.
  • Loading branch information
BlaiseD authored Feb 12, 2022
1 parent 8bf7f07 commit e97fa69
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 67 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Set Variables
run: |
echo "DEPLOY_PACKAGE_URL=https://www.myget.org/F/automapperdev/api/v3/index.json" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100

- name: Set Variables
run: |
echo "DEPLOY_PACKAGE_URL=https://api.nuget.org/v3/index.json" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<RootNamespace>AutoMapper.AspNet.OData</RootNamespace>
<PackageId>AutoMapper.AspNetCore.OData.EF6</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
Expand All @@ -23,22 +23,6 @@
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.1|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.1|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\AutoMapper.AspNetCore.OData.EFCore\AsyncSettings.cs" Link="AsyncSettings.cs" />
<Compile Include="..\AutoMapper.AspNetCore.OData.EFCore\Constants.cs" Link="Constants.cs" />
Expand Down
5 changes: 0 additions & 5 deletions AutoMapper.AspNetCore.OData.EF6/QueryableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using AutoMapper.Extensions.ExpressionMapping;
using LogicBuilder.Expressions.Utils.Expansions;
#if ASPNET
using Microsoft.AspNet.OData.Query;
#endif
#if ASPNETCORE
using Microsoft.AspNetCore.OData.Query;
#endif
using System;
using System.Collections.Generic;
using System.Data.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<RootNamespace>AutoMapper.AspNet.OData</RootNamespace>
<PackageId>AutoMapper.AspNetCore.OData.EFCore</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
Expand All @@ -23,25 +23,28 @@
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;ASPNETCORE</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[5.0.0,6.0.0)" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[5.0.0,6.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="MinVer" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
</ItemGroup>

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

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

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
11 changes: 3 additions & 8 deletions AutoMapper.AspNetCore.OData.EFCore/LinqExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using AutoMapper.AspNet.OData.Visitors;
using LogicBuilder.Expressions.Utils;
using LogicBuilder.Expressions.Utils.Expansions;
#if ASPNET
using Microsoft.AspNet.OData.Query;
#endif
#if ASPNETCORE
using Microsoft.AspNetCore.OData.Query;
#endif
using Microsoft.OData.UriParser;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -257,9 +252,9 @@ private static string GetPropertyPath(this CountNode countNode)
case CollectionNavigationNode navigationNode:
return string.Join(".", new List<string>().GetReferencePath(navigationNode.Source, navigationNode.NavigationProperty.Name));
case null:
throw new ArgumentNullException(nameof(countNode.Source));
throw new ArgumentNullException(nameof(countNode));
default:
throw new ArgumentOutOfRangeException(nameof(countNode.Source));
throw new ArgumentOutOfRangeException(nameof(countNode));
}
}

Expand Down Expand Up @@ -493,7 +488,7 @@ private static List<List<ODataExpansionOptions>> GetExpansions(this IEnumerable<
Type memberType = currentParentType.GetMemberInfo(path).GetMemberType();
Type elementType = memberType.GetCurrentType();

ODataExpansionOptions exp = new ODataExpansionOptions
ODataExpansionOptions exp = new()
{
MemberType = memberType,
ParentType = currentParentType,
Expand Down
9 changes: 1 addition & 8 deletions AutoMapper.AspNetCore.OData.EFCore/ODataSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#if ASPNET
using Microsoft.AspNet.OData.Query;
#endif
#if ASPNETCORE
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Query;
using System;
#endif


namespace AutoMapper.AspNet.OData
Expand All @@ -31,14 +26,12 @@ public class ODataSettings
/// </value>
public int? PageSize { get; set; }

#if ASPNETCORE
/// <summary>
/// Gets of sets the <see cref="TimeZoneInfo"/>.
/// </summary>
/// <value>
/// Default is null.
/// </value>
public TimeZoneInfo TimeZone { get; set; }
#endif
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions AutoMapper.AspNetCore.OData.EFCore/QueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ await query
)
).ToList();

public static async Task ApplyOptionsAsync<TModel, TData>(this IQueryable<TData> query, IMapper mapper, Expression<Func<TModel, bool>> filter, ODataQueryOptions<TModel> options, QuerySettings querySettings)
{
ApplyOptions(options, querySettings);
if (options.Count?.Value == true)
options.AddCountOptionsResult(await query.QueryLongCountAsync(mapper, filter, querySettings?.AsyncSettings?.CancellationToken ?? default));
}

private static IQueryable<TData> GetDataQuery<TModel, TData>(this IQueryable<TData> query, IMapper mapper,
Expression<Func<TModel, bool>> filter = null,
Expression<Func<IQueryable<TModel>, IQueryable<TModel>>> queryFunc = null,
Expand Down Expand Up @@ -161,13 +168,6 @@ private static void ApplyOptions<TModel, TData>(this IQueryable<TData> query, IM
options.AddCountOptionsResult(query.QueryLongCount(mapper, filter));
}

private static async Task ApplyOptionsAsync<TModel, TData>(this IQueryable<TData> query, IMapper mapper, Expression<Func<TModel, bool>> filter, ODataQueryOptions<TModel> options, QuerySettings querySettings)
{
ApplyOptions(options, querySettings);
if (options.Count?.Value == true)
options.AddCountOptionsResult(await query.QueryLongCountAsync(mapper, filter, querySettings?.AsyncSettings?.CancellationToken ?? default));
}

private static void ApplyOptions<TModel>(ODataQueryOptions<TModel> options, QuerySettings querySettings)
{
options.AddExpandOptionsResult();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<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>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

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

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
4 changes: 2 additions & 2 deletions ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

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

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
4 changes: 0 additions & 4 deletions WebAPI.OData.EF6/WebAPI.OData.EF6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutoMapper.AspNetCore.OData.EF6\AutoMapper.AspNetCore.OData.EF6.csproj" />
<ProjectReference Include="..\DAL.EF6\DAL.EF6.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions WebAPI.OData.EFCore/WebAPI.OData.EFCore.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
</ItemGroup>

Expand Down

0 comments on commit e97fa69

Please sign in to comment.