Skip to content

Commit

Permalink
Merge pull request #104 from AutoMapper/v2.2
Browse files Browse the repository at this point in the history
Microsoft.AspNetCore.OData v8.0.1
  • Loading branch information
BlaiseD authored Aug 8, 2021
2 parents 9550608 + 5ef8cc6 commit c196308
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 133 deletions.
11 changes: 9 additions & 2 deletions AutoMapper.AspNet.OData.EF6/AutoMapper.AspNet.OData.EF6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<AssemblyOriginatorKeyFile>..\AutoMapper.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<MinVerTagPrefix>v</MinVerTagPrefix>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down Expand Up @@ -52,12 +58,13 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[4.1.1,5.0.0)" />
<PackageReference Include="EntityFramework" Version="6.2.0" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.1,5.0.0)" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.2,5.0.0)" />
<PackageReference Include="Microsoft.AspNet.OData" Version="7.4.1" />
<PackageReference Include="MinVer" Version="2.3.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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageId>AutoMapper.AspNetCore.OData.EF6</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting Microsoft.AspNetCore.OData v8.0.0-rc.</PackageReleaseNotes>
<PackageReleaseNotes>Supporting Microsoft.AspNetCore.OData v8.0.1.</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIconUrl>https://s3.amazonaws.com/automapper/icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand All @@ -15,6 +15,12 @@
<AssemblyOriginatorKeyFile>..\AutoMapper.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<MinVerTagPrefix>v</MinVerTagPrefix>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
Expand Down Expand Up @@ -60,12 +66,13 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[4.1.1,5.0.0)" />
<PackageReference Include="EntityFramework" Version="6.3.0" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.1,5.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.0-rc" />
<PackageReference Include="MinVer" Version="2.3.0">
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.2,5.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.1" />
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageId>AutoMapper.AspNetCore.OData.EFCore</PackageId>
<Description>Creates LINQ expressions from ODataQueryOptions and executes the query.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Supporting Microsoft.AspNetCore.OData v8.0.0-rc.</PackageReleaseNotes>
<PackageReleaseNotes>Supporting Microsoft.AspNetCore.OData v8.0.1.</PackageReleaseNotes>
<PackageTags>linq expressions odata efcore</PackageTags>
<PackageIconUrl>https://s3.amazonaws.com/automapper/icon.png</PackageIconUrl>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper.Extensions.OData</RepositoryUrl>
Expand All @@ -15,6 +15,12 @@
<AssemblyOriginatorKeyFile>..\AutoMapper.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<MinVerTagPrefix>v</MinVerTagPrefix>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -27,13 +33,14 @@

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.ExpressionMapping" Version="[4.1.1,5.0.0)" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.1,5.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.0-rc" />
<PackageReference Include="LogicBuilder.Expressions.Utils" Version="[4.1.2,5.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="MinVer" Version="2.3.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>
Expand Down
12 changes: 9 additions & 3 deletions AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.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.1" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 9 additions & 5 deletions AutoMapper.OData.EF6.Tests/GetQuerySelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.OData;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
Expand All @@ -29,12 +28,18 @@ public GetQuerySelectTests()
private void Initialize()
{
IServiceCollection services = new ServiceCollection();
services.AddOData();
IMvcCoreBuilder builder = new TestMvcCoreBuilder
{
Services = services
};

builder.AddOData();
services.AddTransient<TestDbContext>(_ => new TestDbContext())
.AddSingleton<IConfigurationProvider>(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly)))
.AddTransient<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService))
.AddTransient<IApplicationBuilder>(sp => new ApplicationBuilder(sp))
.AddTransient<IRouteBuilder>(sp => new RouteBuilder(sp.GetRequiredService<IApplicationBuilder>()));
.AddRouting()
.AddLogging();

serviceProvider = services.BuildServiceProvider();
}
Expand Down Expand Up @@ -182,8 +187,7 @@ private ODataQueryOptions<TModel> GetODataQueryOptions<TModel>(string query) whe
_oDataQueryOptions = ODataHelpers.GetODataQueryOptions<TModel>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
}

Expand Down
33 changes: 16 additions & 17 deletions AutoMapper.OData.EF6.Tests/GetQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
using AutoMapper.OData.EF6.Tests.Model;
using DAL.EF6;
using Domain.OData;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.OData;
using Microsoft.AspNetCore.OData.Extensions;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Microsoft.AspNetCore.OData;

namespace AutoMapper.OData.EF6.Tests
{
Expand All @@ -32,12 +31,18 @@ public GetQueryTests()
private void Initialize()
{
IServiceCollection services = new ServiceCollection();
services.AddOData();
IMvcCoreBuilder builder = new TestMvcCoreBuilder
{
Services = services
};

builder.AddOData();
services.AddTransient<TestDbContext>(_ => new TestDbContext())
.AddSingleton<IConfigurationProvider>(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly)))
.AddTransient<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService))
.AddTransient<IApplicationBuilder>(sp => new ApplicationBuilder(sp))
.AddTransient<IRouteBuilder>(sp => new RouteBuilder(sp.GetRequiredService<IApplicationBuilder>()));
.AddRouting()
.AddLogging();

serviceProvider = services.BuildServiceProvider();
}
Expand Down Expand Up @@ -305,8 +310,7 @@ public async void BuildingExpandBuilderTenantExpandCityFilterOnNestedNestedPrope
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
Test(Get<CoreBuilding, TBuilding>(query, options));
Test(await GetAsync<CoreBuilding, TBuilding>(query, options));
Expand Down Expand Up @@ -366,8 +370,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
Test(Get<CoreBuilding, TBuilding>(query, options));
Test(await GetAsync<CoreBuilding, TBuilding>(query, options));
Expand All @@ -388,8 +391,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options));
Expand Down Expand Up @@ -484,8 +486,7 @@ public async void BuildingWithTopAndSmallerPageSizeNextLink()
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options, new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = pageSize } }));
Expand All @@ -511,8 +512,7 @@ public async void BuildingWithTopAndLargerPageSizeNextLink()
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options, new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = pageSize } }));
Expand Down Expand Up @@ -917,8 +917,7 @@ private ODataQueryOptions<TModel> GetODataQueryOptions<TModel>(string query) whe
_oDataQueryOptions = ODataHelpers.GetODataQueryOptions<TModel>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
}

Expand Down
38 changes: 22 additions & 16 deletions AutoMapper.OData.EF6.Tests/GetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using Domain.OData;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.OData;
using Microsoft.AspNetCore.OData.Extensions;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OData.Edm;
using Microsoft.OData.ModelBuilder;
Expand Down Expand Up @@ -35,12 +35,18 @@ public GetTests()
private void Initialize()
{
IServiceCollection services = new ServiceCollection();
services.AddOData();
IMvcCoreBuilder builder = new TestMvcCoreBuilder
{
Services = services
};

builder.AddOData();
services.AddTransient<TestDbContext>(_ => new TestDbContext())
.AddSingleton<IConfigurationProvider>(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly)))
.AddTransient<IMapper>(sp => new Mapper(sp.GetRequiredService<IConfigurationProvider>(), sp.GetService))
.AddTransient<IApplicationBuilder>(sp => new ApplicationBuilder(sp))
.AddTransient<IRouteBuilder>(sp => new RouteBuilder(sp.GetRequiredService<IApplicationBuilder>()));
.AddRouting()
.AddLogging();

serviceProvider = services.BuildServiceProvider();
}
Expand Down Expand Up @@ -196,8 +202,7 @@ public async void BuildingExpandBuilderTenantExpandCityFilterOnNestedNestedPrope
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
Test(Get<CoreBuilding, TBuilding>(query, options));
Test(await GetAsync<CoreBuilding, TBuilding>(query, options));
Expand Down Expand Up @@ -257,8 +262,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
Test(Get<CoreBuilding, TBuilding>(query, options));
Test(await GetAsync<CoreBuilding, TBuilding>(query, options));
Expand All @@ -279,8 +283,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options));
Expand Down Expand Up @@ -375,8 +378,7 @@ public async void BuildingWithTopAndSmallerPageSizeNextLink()
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options, new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = pageSize } }));
Expand All @@ -402,8 +404,7 @@ public async void BuildingWithTopAndLargerPageSizeNextLink()
ODataQueryOptions<CoreBuilding> options = ODataHelpers.GetODataQueryOptions<CoreBuilding>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);

Test(Get<CoreBuilding, TBuilding>(query, options, new QuerySettings { ODataSettings = new ODataSettings { HandleNullPropagation = HandleNullPropagationOption.False, PageSize = pageSize } }));
Expand Down Expand Up @@ -517,8 +518,7 @@ private ODataQueryOptions<TModel> GetODataQueryOptions<TModel>(string query) whe
_oDataQueryOptions = ODataHelpers.GetODataQueryOptions<TModel>
(
query,
serviceProvider,
serviceProvider.GetRequiredService<IRouteBuilder>()
serviceProvider
);
}

Expand All @@ -528,7 +528,7 @@ private ODataQueryOptions<TModel> GetODataQueryOptions<TModel>(string query) whe

public static class ODataHelpers
{
public static ODataQueryOptions<T> GetODataQueryOptions<T>(string queryString, IServiceProvider serviceProvider, IRouteBuilder routeBuilder) where T : class
public static ODataQueryOptions<T> GetODataQueryOptions<T>(string queryString, IServiceProvider serviceProvider) where T : class
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

Expand Down Expand Up @@ -564,4 +564,10 @@ static HttpRequest BuildRequest(HttpRequest request, Uri uri)

static readonly string BASEADDRESS = "http://localhost:16324";
}

internal class TestMvcCoreBuilder : IMvcCoreBuilder
{
public ApplicationPartManager PartManager { get; set; }
public IServiceCollection Services { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.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.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit c196308

Please sign in to comment.