automapperdev - AutoMapper.AspNet.OData.EF6 2.2.2-alpha.0.2
Creates LINQ expressions from ODataQueryOptions and executes the query.
PM> Install-Package AutoMapper.AspNet.OData.EF6 -Version 2.2.2-alpha.0.2 -Source https://www.myget.org/F/automapperdev/api/v3/index.json
> nuget.exe install AutoMapper.AspNet.OData.EF6 -Version 2.2.2-alpha.0.2 -Source https://www.myget.org/F/automapperdev/api/v3/index.json
> dotnet add package AutoMapper.AspNet.OData.EF6 --version 2.2.2-alpha.0.2 --source https://www.myget.org/F/automapperdev/api/v3/index.json
<PackageReference Include="AutoMapper.AspNet.OData.EF6" Version="2.2.2-alpha.0.2" />
Copy to clipboard
source https://www.myget.org/F/automapperdev/api/v3/index.json
nuget AutoMapper.AspNet.OData.EF6 ~> 2.2.2-alpha.0.2
Copy to clipboard
> choco install AutoMapper.AspNet.OData.EF6 --version 2.2.2-alpha.0.2 --source https://www.myget.org/F/automapperdev/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "automapperdev" -SourceLocation "https://www.myget.org/F/automapperdev/api/v2"
Install-Module -Name "AutoMapper.AspNet.OData.EF6" -RequiredVersion "2.2.2-alpha.0.2" -Repository "automapperdev" -AllowPreRelease
Copy to clipboard
Browse the sources in this package using Visual Studio or WinDbg by configuring the following symbol server URL: https://www.myget.org/F/automapperdev/api/v2/symbolpackage/
AutoMapper.Extensions.OData
Creates LINQ expressions from ODataQueryOptions and executes the query.
NuGet Package Downloads
Usage
To use:
- Configure object maps with explicit expansion.
- Call the GetAsync or GetQueryAsync extension method from your OData controller. IMapper is an AutoMapper interface.
public class CoreBuildingMappings : AutoMapper.Profile
{
public CoreBuildingMappings()
{
CreateMap<TBuilding, CoreBuilding>()
.ForMember(d => d.Name, o => o.MapFrom(s => s.LongName))
.ForMember(d => d.Tenant, o => o.MapFrom(s => s.Mandator))
.ForAllMembers(o => o.ExplicitExpansion());
CreateMap<TBuilder, OpsBuilder>()
.ForAllMembers(o => o.ExplicitExpansion());
CreateMap<TCity, OpsCity>()
.ForAllMembers(o => o.ExplicitExpansion());
}
}
public static async Task<ICollection<TModel>> GetAsync<TModel, TData>(this IQueryable<TData> query, IMapper mapper, ODataQueryOptions<TModel> options, HandleNullPropagationOption handleNullPropagation = HandleNullPropagationOption.Default);
public static async Task<IQueryable<TModel>> GetQueryAsync<TModel, TData>(this IQueryable<TData> query, IMapper mapper, ODataQueryOptions<TModel> options, HandleNullPropagationOption handleNullPropagation = HandleNullPropagationOption.Default);
public class CoreBuildingController : ODataController
{
private readonly IMapper _mapper;
public CoreBuildingController(MyDbContext context, IMapper mapper)
{
Context = context;
_mapper = mapper;
}
MyDbContext Context { get; set; }
[HttpGet]
public async Task<IActionResult> Get(ODataQueryOptions<CoreBuilding> options)
{
return Ok(await Context.BuildingSet.GetQueryAsync(_mapper, options));
}
}
Do not use the EnableQuery Attribute
Using EnableQuery with AutoMapper.Extensions.OData will result in some operations being applied more than once e.g. in the tests,
if TMandator has a total of two records then without EnableQuery applied to the controller action, the OData query http://localhost:16324/opstenant?$skip=1&$top=1&$orderby=Name will return one record as expected. However with EnableQuery applied
no records will be returned because the skip operation has been applied twice.
OData query examples:
http://localhost:<port>/opstenant?$top=5&$expand=Buildings&$filter=Name eq 'One'&$orderby=Name desc
http://localhost:<port>/opstenant?$top=5&$expand=Buildings&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:<port>/opstenant?$filter=Name eq 'One'
http://localhost:<port>/opstenant?$top=5&$expand=Buildings&$orderby=Name desc
http://localhost:<port>/opstenant?$orderby=Name desc
http://localhost:<port>/opstenant?$orderby=Name desc&$count=true
http://localhost:<port>/opstenant?$top=5&$filter=Name eq 'One'&$orderby=Name desc&$count=true
http://localhost:<port>/opstenant?$top=5&$select=Name, Identity
http://localhost:<port>/opstenant?$top=5&$expand=Buildings&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:<port>/opstenant?$top=5&$expand=Buildings($expand=Builder($expand=City))&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:<port>/opstenant?$top=5&$select=Buildings,Name&$expand=Buildings($select=Name,Builder;$expand=Builder($select=Name,City;$expand=City))&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:<port>/corebuilding?$top=5&$expand=Builder,Tenant&$filter=name ne 'One L1'&$orderby=Name desc
http://localhost:<port>/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$filter=name ne 'One L2'&$orderby=Name desc
Removing Task.Run form non-async calls. CancellationToken support. Restricting page size Server-side.
-
.NETFramework 4.6.1
- AutoMapper.Extensions.ExpressionMapping (>= 4.1.2 && < 5.0.0)
- EntityFramework (>= 6.2.0)
- LogicBuilder.Expressions.Utils (>= 4.1.2 && < 5.0.0)
- Microsoft.AspNet.OData (>= 7.4.1)
- .NETFramework 4.6.1: 4.6.1.0
OwnersJimmy Bogard |
AuthorsBlaiseD |
Project URLhttps://github.com/AutoMapper/AutoMapper.Extensions.OData |
LicenseUnknown |
Tagslinq expressions odata ef |
Info80 total downloads |
| 6 downloads for version 2.2.2-alpha.0.2 |
| Download (32.97 KB) |
| Download symbols (14.65 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
2.2.2-alpha.0.2 | 32.97 KB | Thu, 21 Oct 2021 10:21:36 GMT | 6 |
|
||
|
|
2.2.2-alpha.0.1 | 32.96 KB | Thu, 21 Oct 2021 09:50:31 GMT | 1 |
|
||
|
|
2.2.0-preview.1.2 | 32.96 KB | Sun, 08 Aug 2021 18:55:26 GMT | 1 |
|
||
|
|
2.2.0-preview.1.1 | 32.86 KB | Sat, 10 Apr 2021 19:24:18 GMT | 1 |
|
||
|
|
2.2.0-preview.0.3 | 32.86 KB | Sat, 10 Apr 2021 18:53:13 GMT | 1 |
|
||
|
|
2.2.0-preview.0.2 | 32.85 KB | Sat, 10 Apr 2021 18:42:23 GMT | 1 |
|
||
|
|
2.1.2-alpha.0.1 | 32.86 KB | Sat, 10 Apr 2021 14:59:30 GMT | 1 |
|
||
|
|
2.1.1-preview.0.1 | 32.86 KB | Mon, 22 Feb 2021 16:05:18 GMT | 1 |
|
||
|
|
2.1.1-alpha.2.3 | 32.85 KB | Mon, 22 Feb 2021 15:25:33 GMT | 1 |
|
||
|
|
2.1.1-alpha.1.2 | 32.23 KB | Wed, 10 Feb 2021 19:24:46 GMT | 1 |
|
||
|
|
2.1.1-alpha.0.2 | 32.09 KB | Wed, 10 Feb 2021 15:00:23 GMT | 1 |
|
||
|
|
2.1.1-alpha.0.1 | 31.33 KB | Fri, 04 Dec 2020 12:38:04 GMT | 1 |
|
||
|
|
2.0.3-preview.2.2 | 31.34 KB | Fri, 27 Nov 2020 13:02:58 GMT | 1 |
|
||
|
|
2.0.3-preview.2.1 | 31.09 KB | Thu, 12 Nov 2020 20:17:26 GMT | 1 |
|
||
|
|
2.0.3-preview.1.1 | 31.09 KB | Thu, 12 Nov 2020 19:34:15 GMT | 1 |
|
||
|
|
2.0.3-preview.0.2 | 31.08 KB | Mon, 09 Nov 2020 11:49:40 GMT | 1 |
|
||
|
|
2.0.3-preview.0.1 | 31.08 KB | Mon, 09 Nov 2020 11:13:48 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.6 | 30.87 KB | Mon, 02 Nov 2020 20:11:22 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.5 | 30.88 KB | Mon, 02 Nov 2020 19:20:25 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.4 | 30.86 KB | Thu, 29 Oct 2020 13:14:43 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.3 | 30.85 KB | Thu, 29 Oct 2020 12:39:43 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.2 | 30.86 KB | Thu, 29 Oct 2020 11:59:18 GMT | 1 |
|
||
|
|
2.0.3-alpha.0.1 | 30.16 KB | Mon, 26 Oct 2020 13:45:46 GMT | 1 |
|
||
|
|
2.0.2-preview.1.1 | 30.16 KB | Mon, 26 Oct 2020 12:56:18 GMT | 2 |
|
||
|
|
2.0.2-preview.0.4 | 30.16 KB | Thu, 22 Oct 2020 13:06:09 GMT | 1 |
|
||
|
|
2.0.2-preview.0.3 | 30.17 KB | Thu, 22 Oct 2020 10:11:14 GMT | 1 |
|
||
|
|
2.0.2-preview.0.2 | 30.16 KB | Fri, 18 Sep 2020 10:24:14 GMT | 1 |
|
||
|
|
2.0.2-preview.0.1 | 30.17 KB | Wed, 16 Sep 2020 17:29:42 GMT | 1 |
|
||
|
|
2.0.2-alpha.0.2 | 30.16 KB | Wed, 16 Sep 2020 16:56:51 GMT | 2 |
|
||
|
|
2.0.2-alpha.0.1 | 30.38 KB | Tue, 08 Sep 2020 15:00:22 GMT | 1 |
|
||
|
|
2.0.1-preview-1 | 18.89 KB | Tue, 21 Jul 2020 17:29:28 GMT | 1 |
|
||
|
|
2.0.1-preview.1.2 | 30.39 KB | Tue, 08 Sep 2020 14:15:00 GMT | 2 |
|
||
|
|
2.0.1-preview.1.1 | 30.41 KB | Fri, 04 Sep 2020 15:02:59 GMT | 1 |
|
||
|
|
2.0.1-preview.0.2 | 30.41 KB | Fri, 04 Sep 2020 14:26:56 GMT | 1 |
|
||
|
|
2.0.1-preview.0.1 | 30.65 KB | Thu, 27 Aug 2020 11:08:38 GMT | 1 |
|
||
|
|
2.0.1-alpha.0.3 | 30.66 KB | Wed, 26 Aug 2020 20:44:43 GMT | 2 |
|
||
|
|
2.0.1-alpha.0.2 | 18.88 KB | Thu, 20 Aug 2020 15:46:16 GMT | 1 |
|
||
|
|
2.0.0 | 18.9 KB | Wed, 08 Jul 2020 00:35:36 GMT | 1 |
|
||
|
|
2.0.0-preview02 | 18.96 KB | Mon, 06 Jul 2020 19:19:32 GMT | 1 |
|
||
|
|
1.0.5 | 18.97 KB | Mon, 25 May 2020 21:11:02 GMT | 2 |
|
||
|
|
1.0.5-preview01 | 19.01 KB | Mon, 25 May 2020 17:53:31 GMT | 1 |
|
||
|
|
1.0.4 | 18.92 KB | Sun, 24 May 2020 15:36:14 GMT | 1 |
|
||
|
|
1.0.4-preview04 | 18.96 KB | Sat, 23 May 2020 14:38:11 GMT | 2 |
|
||
|
|
1.0.4-preview03 | 18.53 KB | Sun, 17 May 2020 14:55:04 GMT | 2 |
|
||
|
|
1.0.4-preview02 | 18.46 KB | Sun, 17 May 2020 13:28:43 GMT | 2 |
|
||
|
|
1.0.4-preview01 | 18.59 KB | Thu, 14 May 2020 10:29:49 GMT | 1 |
|
||
|
|
1.0.3 | 18.56 KB | Wed, 13 May 2020 10:05:54 GMT | 3 |
|
||
|
|
1.0.3-preview01 | 18.6 KB | Sun, 03 May 2020 17:30:28 GMT | 2 |
|
||
|
|
1.0.2 | 18.56 KB | Sun, 03 May 2020 13:18:22 GMT | 2 |
|
||
|
|
1.0.2-preview05 | 18.59 KB | Sat, 02 May 2020 18:12:12 GMT | 1 |
|
||
|
|
1.0.2-preview04 | 18.56 KB | Wed, 29 Apr 2020 21:12:52 GMT | 2 |
|
||
|
|
1.0.2-preview03 | 18.53 KB | Tue, 28 Apr 2020 10:15:25 GMT | 2 |
|
||
|
|
1.0.2-preview01 | 15.74 KB | Tue, 21 Apr 2020 09:29:41 GMT | 1 |
|
||
|
|
1.0.1 | 15.76 KB | Sun, 08 Mar 2020 14:36:28 GMT | 1 |
|
||
|
|
1.0.1-preview02 | 15.78 KB | Wed, 05 Feb 2020 22:39:14 GMT | 1 |
|
||
|
|
1.0.1-preview01 | 14.71 KB | Tue, 04 Feb 2020 10:31:22 GMT | 2 |
|
||
|
|
1.0.0 | 12.66 KB | Wed, 11 Sep 2019 22:52:11 GMT | 1 |
|
||
|
|
1.0.0-preview07 | 12.7 KB | Mon, 09 Sep 2019 23:05:22 GMT | 1 |
|
||
|
|
1.0.0-preview06 | 12.69 KB | Mon, 09 Sep 2019 20:39:41 GMT | 2 |
|