-
Notifications
You must be signed in to change notification settings - Fork 711
Core 2.1 ODATA with optional parameters #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
so SelectCandidates executes code of versioning (which i couldn't properly compile & debug). |
I can confirm that the following does not work with aspnet-api-versioning but works without it. With aspnet-api-versioning calling /odata/Items/RecentlyAwarded routes to the Get(string key) instead with RecentlyAwarded as key parameter! It's not even related to .Optional(). I think it's related to .Collection. builder
.EntityType<Item>()
.Collection
.Function(nameof(ItemsController.RecentlyAwarded))
.ReturnsFromEntitySet<Item>("Items");
public class ItemsController
{
[EnableQuery(MaxExpansionDepth = 10)]
public new ActionResult Get()
{
}
[EnableQuery(MaxExpansionDepth = 10)]
public ActionResult Get([FromODataUri] string key)
{
}
[HttpGet]
[EnableQuery(MaxExpansionDepth = 10)]
public IActionResult RecentlyAwarded()
{
}
} |
possibly, but if you try without .Collection, it won't call the action properly either.. |
The excerpts in @flieks post highlights snippets from the OData library and what looks like MVC. The design of the IActionSelector and the various concrete implementations do not allow it to be extended in a way that can support API versioning. This service is completely replaced in MVC and now has a specialized subclass for OData. Looking at the original implementation only helps to compare and contrast because everything had to be reimplemented. In the case of OData, there are quite a few differences in the implementation because the OData design assumes that you can only get a single match. Fortunately, the I also made some other enhancements such that the OData attribute information is actually pre-calculated and attached as actual route information via Ultimately, it looks like this issue is caused by a flaw in the route selection as already noted in #336. The cause appears to be due to not correctly setting the matching action in the route parameters. I should have a fix out this week. I tried the Items example provided by @bdebaere with the forthcoming fix and it appears to work as expected. |
Uh oh!
There was an error while loading. Please reload this page.
Optional parameters aren't working with OData & latest Api versioning 3.0 beta 1.
i'm using latest of OData api and debugged their source code
But then in mvcRouteHandler it can't find a candidate
which is strange cause because in NavigationSourceRoutingConvention it could find a proper actionDescriptor. And the optional property was added to
controllerContext.RouteData.Add(ODataRouteConstants.OptionalParameters, optional);
maybe related to issue 340
The text was updated successfully, but these errors were encountered: