$expand cannot be used with an action bound to a collection when using Microsoft.AspNetCore.OData 8.0.7
@xuzhg is already working on this.
Since Feb 8, 2022.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.