Closed lenardchristopher closed 8 months ago
Great idea.
What does it buy you though over the following:
public async Task<OrderDTO> GetAsync(ODataQueryOptions<OrderDTO> options, [FromODataUri] Guid key) =>
(
await this.context.Orders
.Where(x => x.OrderId == key)
.GetQueryAsync(this.mapper, options)
)
.Single();
@BlaiseD what extension is giving you Single()
? I don't see to have that available.
Nevermind. You are correct. I ended up with something like this
public async Task<ActionResult> GetAsync(ODataQueryOptions<OrderDTO> options, [FromODataUri] Guid key) =>
this.Ok((await this.context.Orders
.Where(x => x.OrderId == key)
.GetQueryAsync(this.mapper, options))
.Single());
The response format looks good to me. No need for SingleResult.Create
. I think this is probably closable unless it's still something you want to address.
Correct - didn't mean to include SingleResult.Create
in the previous comment.
Source/destination types
Mapping configuration
Version: x.y.z
- AutoMapper 12.0.1 - AutoMapper.AspNetCore.OData.EFCore 4.0.1 - Microsoft.AspNetCore.OData 8.2.3 ### Expected behaviorUsing
ProjectTo
, you can useEnableQueryAttribute
andSingleResult
like this. The docs say for use with[EnableQuery]
. However, when using AutoMapper.Extensions.OData, you aren't supposed to use that attribute.I expected to be able to remove
EnableQueryAttribute
and useGetQueryAsync
Actual behavior
I get this error
Steps to reproduce
SingleResult
passing in the awaited IQueryable from GetQueryAsync