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

LINQ: Simplify multiple Where clauses in LINQ Query into a single $match clause.

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      var query1 = collection.AsQueryable()
                       .Where(c => !(c.Age > 1))
                       .Where(c => c.Age < 100); { "$match" : { "entity.age" : { "$not" :

      { "$gt" : 1 }

      } } }, { "$match" : { "entity.age" :

      { "$lt" : 100 }

      } }])}var query2 = collection.AsQueryable()
                       .Where(c => !(c.Age > 1) && c.Age < 100);{ "$match" : { "entity.age" : { "$not" :

      { "$gt" : 1 }

      , "$lt" : 100 } } }])}

      Is there a provision for Mongo C# driver to interpret the above two interpretation of similar linq statement as same mongo query i.e with a single $match instead of seperate $match for each where clauses, the obvious answer for the above problem is identify all the queries with multiple where claused to a single where clause. Other than that do we  have any other suggestions.

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            rajesh.vinayagam@mongodb.com Rajesh Vinayagam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: