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

In memory filtering after ODataQueryOptions.ApplyTo() #2732

Open
xubinzheng opened this issue Dec 1, 2022 · 1 comment
Open

In memory filtering after ODataQueryOptions.ApplyTo() #2732

xubinzheng opened this issue Dec 1, 2022 · 1 comment

Comments

@xubinzheng
Copy link

xubinzheng commented Dec 1, 2022

I want to follow up on this very old ticket: #521

This issue was raised in 2015, and the same limitation seems still exist in the Odata.ApplyTo(). I am wondering is there a better solution than You can do this to check for a $select wrapper, get a Dictionary of key,values and then map it your model. at this moment?
image

Similar to the original question, I am trying to perform in memory filtering of a query, after it has been retrieved from the downstream API, and before returning it to the client.

Using ODataQueryOptions.ApplyTo(...) I can let OData do all it's query magic on the in-memory data. However if $expand or $select has been supplied, the returned IQueryable contains not the entities themselves, but SelectExpandWrapper objects. Which it is impossible to extract the original entity from.

Ideally I would like to be able to do something like this in a controller action

public IQueryable<Entity> GetFeed(ODataQueryOptions<Entity> opts)
{
    IQueryable<Entity> result = opts.ApplyTo(<IEnumerable>.AsQueryable<Entity>())

    foreach (var item in result)
    {
        // perform extra filtering here
    }
    return result;
}

Expected result

Any suggestions will be very helpful.

@michallabuzsybilla
Copy link

I am also interested in this. Anything new?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants