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

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

Open
LinusCenterstrom opened this issue Jan 31, 2024 · 0 comments · May be fixed by #124
Open

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

LinusCenterstrom opened this issue Jan 31, 2024 · 0 comments · May be fixed by #124
Labels
analysis Problem analysis

Comments

@LinusCenterstrom
Copy link

LinusCenterstrom commented Jan 31, 2024

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')");
LinusCenterstrom added a commit to LinusCenterstrom/OData.QueryBuilder that referenced this issue Jan 31, 2024
…ny/all conditions on the root level.

Possible breaking:
Changed the All and Any methods to take Expression<Func<T, bool>> instead of Func<T, bool>.
As far as I can tell this does not impact anything since explicitly passing a non-null Func<T, bool> previously was unsupported.

fixes ZEXSM#123
@ZEXSM ZEXSM added the analysis Problem analysis label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Problem analysis
Projects
None yet
2 participants