OData / OData/AspNetCoreOData

$expand cannot be used with an action bound to a collection when using Microsoft.AspNetCore.OData 8.0.7

Open
#474 6 comments 0 reactions 1 assignee View on GitHub

@xuzhg is already working on this.

Since Feb 8, 2022.

followup investigated
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

@xuzhg Unfortunately I think I have found an error in your OData 8.0.7 component. I would like to tell, that it worked excellently in OData 7.4.1

The problem is, that $expand presumably cannot be used with an action bound to a collection when using Microsoft.AspNetCore.OData 8.0.7.

Project which documents the problem: https://github.com/henrikdahl8240/AttributeRouting80Rc, which is based on your project having the same name, but obviously different.

As we talk about actions, we talk about POSTs.

Works:
http://localhost:56394/odata/books(1)/Default.LookupById

Works:
http://localhost:56394/odata/books(1)/Default.LookupById?$expand=Press

Works:
http://localhost:56394/odata/books/Default.LookupByIds

Gives Exception:
http://localhost:56394/odata/books/Default.LookupByIds?$expand=Press

The exception:
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. The property 'Press' cannot be used in the $expand query option.",
"details": [],
"innererror": {
"message": "The property 'Press' cannot be used in the $expand query option.",
"type": "Microsoft.OData.ODataException",
"stacktrace": " at Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.ValidateRestrictions(Nullable`1 remainDepth, Int32 currentDepth, SelectExpandClause selectExpandClause, IEdmNavigationProperty navigationProperty, ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.Validator.SelectExpandQueryValidator.Validate(SelectExpandQueryOption selectExpandQueryOption, ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.SelectExpandQueryOption.Validate(ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.Validator.ODataQueryValidator.Validate(ODataQueryOptions options, ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.ODataQueryOptions.Validate(ODataValidationSettings validationSettings)\r\n at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ValidateQuery(HttpRequest request, ODataQueryOptions queryOptions)\r\n at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuting(ActionExecutingContext actionExecutingContext)"
}
}
}

I hope you may quickly solve the problem, because it prevents me from going for .NET 6 and OData 8.0.7.

In case there is some configuration I have missed, I would like to excuse, that I think there is an error. But I think, that there is an error.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.