[CSHARP-3407] LINQ3: Translate a.Any() with no predicate in filters Created: 06/Feb/21  Updated: 28/Oct/23  Resolved: 04/Oct/21

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: None
Fix Version/s: 2.14.0

Type: Task Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CSHARP-3404 LINQ3: Get LegacyPredicateTranslatorT... Closed
Epic Link: CSHARP-2608

 Description   

Translate a.Any() with no predicate in filters.

For example:

collection.Where(x => x.A.Any())

translates to:

{ $match : {
    $and : [
        { A : { $ne : null } },
        { $nor : [ { A : { $size : 0 } } ] }
    ]
} }

 
The check for A not null is because we deem the null value to not match the Any condition.

The use of $nor with one argument is to simulate logical negation. We can't use $not because that has different semantics (and limitations) in the filter language.



 Comments   
Comment by Robert Stam [ 06/Feb/21 ]

Done but not reviewed

Generated at Wed Feb 07 21:45:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.