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

LINQ should translate false bool expressions to {a : false} rather than {a : {$ne : true}}

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.6
    • Component/s: None

      The following LINQ Expression:

      ...Where(d => !d.BoolField)
      

      Translates to {BoolField : {$ne : true.}} Well, this is not great for performance and the expression is not able to use an index as well as

      {BoolField : false}

      would be able to use the index.

      Since in the driver serialization, we know that the field will always be serialized to bool, it would be better to translate the expression to

      {BoolField : false}

      instead.

      (Note that (d => d.BoolField == false) appears to translate correctly.)

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            zaidmasud Zaid Masud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: