OData / OData/AspNetCoreOData

Feature ask: support in memory filtering after ODataQueryOptions.ApplyTo()

Open
#766 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

I want to follow up on this very old ticket: https://github.com/OData/WebApi/issues/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at ODataQueryOptions.ApplyTo(...) and trace how $select and $expand produce SelectExpandWrapper results for in-memory IQueryable data. Compare this behavior with the earlier issue linked in the description; done means a supported way to apply additional in-memory filtering while preserving the requested OData projection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.