Skip to content

Allow simpler creation of ODataQueryOptions<TEntity> #1531

@wertzui

Description

@wertzui

At the moment all the constructor of ODataQueryOptions<TEntity> and the static BindAsync methods need the HttpRequest or the HttpRequest which makes it hard to create an instance of the class on the fly.

It would be way easier to have methods/constructors which just take in in IDictionary<string, string> or ODataRawQueryOptions (if the setter are made public) and an optional IEdmModel (would be null for non-model scenarios).

My current goal is to parse these from a simple JSON object in order to create an MCP Tool with OData capabilities, but I'm sure that it would benefit others.

My current approach to achieve this is to get the values into a Dictionary<string, string>, then set httpContext.QueryString, use Reflection to create an instance of the ODataQueryParameterBinding through new ODataQueryParameterBindingAttribute().BinderType, and having my own ModelBindingContext which just delegates stuff to the HttpContext.
This is way to complicated in order to just create an instance of ODataQueryOptions<TEntity> and it should be easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions