diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e075d3d..f60ee19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a20d891..d3f4b69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj b/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj index bcac1b8..9dd29f8 100644 --- a/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj +++ b/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net5.0;net6.0 AutoMapper.AspNet.OData AutoMapper.AspNetCore.OData.EF6 Creates LINQ expressions from ODataQueryOptions and executes the query. @@ -23,22 +23,6 @@ true - - TRACE;ASPNETCORE - - - - TRACE;ASPNETCORE - - - - TRACE;ASPNETCORE - - - - TRACE;ASPNETCORE - - diff --git a/AutoMapper.AspNetCore.OData.EF6/QueryableExtensions.cs b/AutoMapper.AspNetCore.OData.EF6/QueryableExtensions.cs index 0bfe124..9af8dc1 100644 --- a/AutoMapper.AspNetCore.OData.EF6/QueryableExtensions.cs +++ b/AutoMapper.AspNetCore.OData.EF6/QueryableExtensions.cs @@ -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; diff --git a/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj b/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj index e56a263..95a913a 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj +++ b/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + netcoreapp3.1;net5.0;net6.0 AutoMapper.AspNet.OData AutoMapper.AspNetCore.OData.EFCore Creates LINQ expressions from ODataQueryOptions and executes the query. @@ -23,25 +23,28 @@ true - - TRACE;ASPNETCORE - - - - TRACE;ASPNETCORE - - - all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/AutoMapper.AspNetCore.OData.EFCore/LinqExtensions.cs b/AutoMapper.AspNetCore.OData.EFCore/LinqExtensions.cs index af2e8b9..59823a9 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/LinqExtensions.cs +++ b/AutoMapper.AspNetCore.OData.EFCore/LinqExtensions.cs @@ -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; @@ -257,9 +252,9 @@ private static string GetPropertyPath(this CountNode countNode) case CollectionNavigationNode navigationNode: return string.Join(".", new List().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)); } } @@ -493,7 +488,7 @@ private static List> GetExpansions(this IEnumerable< Type memberType = currentParentType.GetMemberInfo(path).GetMemberType(); Type elementType = memberType.GetCurrentType(); - ODataExpansionOptions exp = new ODataExpansionOptions + ODataExpansionOptions exp = new() { MemberType = memberType, ParentType = currentParentType, diff --git a/AutoMapper.AspNetCore.OData.EFCore/ODataSettings.cs b/AutoMapper.AspNetCore.OData.EFCore/ODataSettings.cs index 3a1db2e..56db567 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/ODataSettings.cs +++ b/AutoMapper.AspNetCore.OData.EFCore/ODataSettings.cs @@ -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 @@ -31,7 +26,6 @@ public class ODataSettings /// public int? PageSize { get; set; } -#if ASPNETCORE /// /// Gets of sets the . /// @@ -39,6 +33,5 @@ public class ODataSettings /// Default is null. /// public TimeZoneInfo TimeZone { get; set; } -#endif } } diff --git a/AutoMapper.AspNetCore.OData.EFCore/Properties/Resources.Designer.cs b/AutoMapper.AspNetCore.OData.EFCore/Properties/Resources.Designer.cs index 9f60eff..892f06b 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/Properties/Resources.Designer.cs +++ b/AutoMapper.AspNetCore.OData.EFCore/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace AutoMapper.AspNet.OData.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/AutoMapper.AspNetCore.OData.EFCore/QueryableExtensions.cs b/AutoMapper.AspNetCore.OData.EFCore/QueryableExtensions.cs index 98bfaae..820da81 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/QueryableExtensions.cs +++ b/AutoMapper.AspNetCore.OData.EFCore/QueryableExtensions.cs @@ -94,6 +94,13 @@ await query ) ).ToList(); + public static async Task ApplyOptionsAsync(this IQueryable query, IMapper mapper, Expression> filter, ODataQueryOptions 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 GetDataQuery(this IQueryable query, IMapper mapper, Expression> filter = null, Expression, IQueryable>> queryFunc = null, @@ -161,13 +168,6 @@ private static void ApplyOptions(this IQueryable query, IM options.AddCountOptionsResult(query.QueryLongCount(mapper, filter)); } - private static async Task ApplyOptionsAsync(this IQueryable query, IMapper mapper, Expression> filter, ODataQueryOptions 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(ODataQueryOptions options, QuerySettings querySettings) { options.AddExpandOptionsResult(); diff --git a/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj b/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj index 7e230b5..4bb633e 100644 --- a/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj +++ b/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false diff --git a/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj b/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj index 3c4e143..4a2d724 100644 --- a/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj +++ b/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj @@ -1,13 +1,13 @@  - netcoreapp3.1 + net6.0 false - + diff --git a/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj b/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj index 38b8456..f5e34c6 100644 --- a/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj +++ b/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj @@ -1,13 +1,13 @@ - netcoreapp3.1 + net6.0 false - + diff --git a/WebAPI.OData.EF6/WebAPI.OData.EF6.csproj b/WebAPI.OData.EF6/WebAPI.OData.EF6.csproj index f2c2c31..01ee805 100644 --- a/WebAPI.OData.EF6/WebAPI.OData.EF6.csproj +++ b/WebAPI.OData.EF6/WebAPI.OData.EF6.csproj @@ -4,10 +4,6 @@ net5.0 - - - - diff --git a/WebAPI.OData.EFCore/WebAPI.OData.EFCore.csproj b/WebAPI.OData.EFCore/WebAPI.OData.EFCore.csproj index ab5dd33..aeda721 100644 --- a/WebAPI.OData.EFCore/WebAPI.OData.EFCore.csproj +++ b/WebAPI.OData.EFCore/WebAPI.OData.EFCore.csproj @@ -1,11 +1,11 @@  - net5.0 + netcoreapp3.1 - +