Skip to content
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

Cannot override GetModel method from EnableQueryAttribute #537

Closed
kjaworski opened this issue Mar 23, 2022 · 9 comments · Fixed by #553
Closed

Cannot override GetModel method from EnableQueryAttribute #537

kjaworski opened this issue Mar 23, 2022 · 9 comments · Fixed by #553
Assignees
Labels
bug Something isn't working

Comments

@kjaworski
Copy link
Contributor

Before it was possible to override GetModel method from EnableQueryAttribute for customizations. That's also what "summary" doc says. But it was changed from "virtual" to "static" in this commit:

daba950

@julealgon
Copy link
Contributor

Looks like it was changed inadvertently because of where it is called, ContainsAutoSelectExpandProperty, which is static (but doesn't seem to need to be).

@xuzhg
Copy link
Member

xuzhg commented Mar 23, 2022

@julealgon I think you are right. it could be an accident. I'd like to revert it.

@kjaworski if you want to return the model by yourself, now, you can set your model on the HttpRequest in the controller action.

for example:

public class controller...
{

    [enablequery]
    public IActionResult Get()
    {
          ......
          Request.ODataFeature().Model = yourmodel;
    }
}

@kjaworski
Copy link
Contributor Author

@xuzhg Could you please prioritize this one?

It prevents our company from upgrading our products to .NET 6. The workaround will do the trick of course, but we have hundreds of controllers decorating our attribute which inherits from EnableQueryAttribute.

The origin of our issue is extraction of IServiceCollection to separate "Abstractions" namespace, so BuildContainer() from DefaultContainerBuilder gets the same error as this one:
dotnet/aspnet-api-versioning#796
There are comments that upgrade to 7.5.12 helps, but it doesn't work for us.

@habbes habbes added the bug Something isn't working label Mar 30, 2022
@kjaworski
Copy link
Contributor Author

@xuzhg @habbes Can I submit my fix? I tried to push my branch, but I have no permission to do so.

@julealgon
Copy link
Contributor

I tried to push my branch, but I have no permission to do so.

Create a fork of the project, push your changes there, and then create a PR from your fork's branch into the main repo.

@kjaworski
Copy link
Contributor Author

I tried to push my branch, but I have no permission to do so.

Create a fork of the project, push your changes there, and then create a PR from your fork's branch into the main repo.

Thanks! I didn't know the "forking" workflow yet. PR ready.

@kjaworski
Copy link
Contributor Author

Any plans for next release? When can we expect this?

@xuzhg
Copy link
Member

xuzhg commented Apr 14, 2022

@kjaworski https://www.nuget.org/packages/Microsoft.AspNetCore.OData/8.0.9 is out. Please try and let me know any problems.

@kjaworski
Copy link
Contributor Author

@xuzhg Thanks a lot, works ok in 8.0.9!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants