Skip to content

Ability to share Filter expressions between the expand level and the root level #123

@LinusCenterstrom

Description

@LinusCenterstrom

Consider the following:
You want to get top X items which have an expand with at least one value matching condition Y.
For the expand you also only want to include items matching condition Y.
As far as I can tell, it's currently impossible to reuse the expressions from the filter on the expand with the Any condition on the root query level which means you would have to define that condition twice.

Simple example of how I imagine the call would look (using your test classes)

Expression<Func<string, bool>> isTestTag = t => t == "testTag";
            
var uri = _odataQueryBuilderDefault
    .For<ODataTypeEntity>(s => s.ODataType)
    .ByList()
    .Expand(x => x.For<string>(t => t.Tags).Filter(isTestTag))
    .Filter((s, f, o) => o.Any(s.Tags, isTestTag))
    .ToUri();

uri.Should().Be("http://mock/odata/ODataType?$expand=Tags($filter='testTag')&$filter=Tags/any(t:t eq 'testTag')");

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisProblem analysis

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions