Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3407

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

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.14.0
    • Affects Version/s: None
    • Component/s: LINQ3
    • Labels:
      None

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: