-
Notifications
You must be signed in to change notification settings - Fork 170
Controllers with same name in different namespace #37
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
Finally I managed do solve this on my own. Anybody having the same issue, I'll quickly describe my solution: 1.: I introduced an interface
2.: I introduced an
3.: I replaced every built-in routing convention (see https://devblogs.microsoft.com/odata/routing-in-asp-net-core-8-0-preview/#built-in-conventional-routings) with a new one that uses the
So my services.AddOData call now looks like this:
I'm leaving the issue open, as my note that the Order-Property in EntityRoutingConvention is not virtual should be considered. |
I had the same errors (AmbiguousMatchException) but in my case, the solution is very simple: Add models:
And in the controllers (in different namespaces) you need to use the attribute ODataModel.
And now you can call the API:
|
@ra-design Thanks for your question and workaround. We do appreciate. Actually, just like @fabiocbr75 's comment, [ODataModelAttribute] is designed to resolve the scenario like yours. it's more easy. For the virtual Order, i will fix it. Thanks for it and looking forward more feedback from you. |
See "virtual Order" at 002f78c. Thanks. |
@fabiocbr75, @xuzhg: Thank you, couldn't find this solution somehow, thanks for pointing this out! |
Hi, I'm trying to update our current webapi to odata, where I have controllers with the same name in different namespaces.
The underlying entity types are in different DbContexts (different Databases), the DbContexts are in separate IEdmModels with different odata prefixes.
odata/erp/customers
(prefix: odata/erp) should resolve to controller WebService.Erp.Controllers.CustomersControllerodata/crm/customers
(prefix: odata/crm) should resolve to controller WebService.Crm.Controllers.CustomersControllerI'm getting an AmbiguousMatchException: The request matched multiple endpoints. when calling one endpoint and a 404 reply when requesting the other, so both requests route to the same controller.
Could someone point me in the right direction or how to tackle this problem? Am I missing something here? I tried to set a custom routing convention (https://devblogs.microsoft.com/odata/routing-in-asp-net-core-8-0-preview/), but to no effect.
Btw, i noticed that Order in EntityRoutingConvention is not virtual - don't know if for a reason, but seems odd as it's virtual in the others:
AspNetCoreOData/src/Microsoft.AspNetCore.OData/Routing/Conventions/EntityRoutingConvention.cs
Line 30 in db021ff
The text was updated successfully, but these errors were encountered: