AutoMapper.AspNetCore.OData.EFCore
10.0.0
Prefix Reserved
dotnet add package AutoMapper.AspNetCore.OData.EFCore --version 10.0.0
NuGet\Install-Package AutoMapper.AspNetCore.OData.EFCore -Version 10.0.0
paket add AutoMapper.AspNetCore.OData.EFCore --version 10.0.0
#r "nuget: AutoMapper.AspNetCore.OData.EFCore, 10.0.0"
#:package AutoMapper.AspNetCore.OData.EFCore@10.0.0
#addin nuget:?package=AutoMapper.AspNetCore.OData.EFCore&version=10.0.0
#tool nuget:?package=AutoMapper.AspNetCore.OData.EFCore&version=10.0.0
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()
.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()
.ForAllMembers(o => o.ExplicitExpansion());
CreateMap()
.ForAllMembers(o => o.ExplicitExpansion());
}
}
public static async Task> GetQueryAsync(this IQueryable query, IMapper mapper, ODataQueryOptions 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 Get(ODataQueryOptions 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:/opstenant?$top=5&$expand=Buildings&$filter=Name eq 'One'&$orderby=Name desc
http://localhost:/opstenant?$top=5&$expand=Buildings&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:/opstenant?$filter=Name eq 'One'
http://localhost:/opstenant?$top=5&$expand=Buildings&$orderby=Name desc
http://localhost:/opstenant?$orderby=Name desc
http://localhost:/opstenant?$orderby=Name desc&$count=true
http://localhost:/opstenant?$top=5&$filter=Name eq 'One'&$orderby=Name desc&$count=true
http://localhost:/opstenant?$top=5&$select=Name, Identity
http://localhost:/opstenant?$top=5&$expand=Buildings&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:/opstenant?$top=5&$expand=Buildings($expand=Builder($expand=City))&$filter=Name ne 'One'&$orderby=Name desc
http://localhost:/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:/corebuilding?$top=5&$expand=Builder,Tenant&$filter=name ne 'One L1'&$orderby=Name desc
http://localhost:/corebuilding?$top=5&$expand=Builder($expand=City),Tenant&$filter=name ne 'One L2'&$orderby=Name desc
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AutoMapper.Extensions.ExpressionMapping (>= 11.0.0 && < 12.0.0)
- LogicBuilder.Expressions.Utils (>= 8.0.0)
- Microsoft.AspNetCore.OData (>= 9.4.1)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
-
net8.0
- AutoMapper.Extensions.ExpressionMapping (>= 11.0.0 && < 12.0.0)
- LogicBuilder.Expressions.Utils (>= 8.0.0)
- Microsoft.AspNetCore.OData (>= 9.4.1)
- Microsoft.EntityFrameworkCore (>= 8.0.22)
-
net9.0
- AutoMapper.Extensions.ExpressionMapping (>= 11.0.0 && < 12.0.0)
- LogicBuilder.Expressions.Utils (>= 8.0.0)
- Microsoft.AspNetCore.OData (>= 9.4.1)
- Microsoft.EntityFrameworkCore (>= 9.0.11)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AutoMapper.AspNetCore.OData.EFCore:
| Package | Downloads |
|---|---|
|
RESTworld.AspNetCore
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 45,678 | 4/1/2026 |
| 9.1.0 | 6,959 | 3/10/2026 |
| 9.0.0 | 7,773 | 12/19/2025 |
| 8.1.0 | 10,905 | 11/23/2025 |
| 8.0.0 | 39,145 | 7/12/2025 |
| 7.0.4 | 145,122 | 7/5/2025 |
| 7.0.2 | 78,170 | 5/10/2025 |
| 7.0.1 | 72,687 | 4/23/2025 |
| 7.0.0 | 95,031 | 2/15/2025 |
| 6.1.1 | 39,015 | 1/19/2025 |
| 6.1.0 | 10,255 | 1/3/2025 |
| 6.0.0 | 52,965 | 11/27/2024 |
| 5.0.2 | 1,940,010 | 7/27/2024 |
| 5.0.1 | 93,326 | 6/13/2024 |
| 5.0.0 | 840,250 | 2/19/2024 |
| 4.0.2 | 84,190 | 12/28/2023 |
| 4.0.1 | 187,761 | 8/19/2023 |
| 4.0.0 | 397,449 | 10/1/2022 |
| 3.0.6 | 23,271 | 10/1/2022 |
| 3.0.5 | 214,985 | 6/17/2022 |
Removing obsolete methods and using the latest version of AutoMapper.Extensions.ExpressionMapping. Ending maintenance for AutoMapper.AspNetCore.OData.EF6.