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

Support for Filters without name in C# Driver

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.3
    • Component/s: Linq
    • Labels:
      None
    • Environment:
      Windows, Mac, C#, MongoDB 3.2, C# Driver 2.2.3 and earlier.

      I'm trying to translate following MongoDB shell query into C# query.

      db.col.find({"Details.a":{$elemMatch:{$elemMatch:{DeviceName : /.Name0./}}}});
      

      As you can see $elemMatch is nested into another $elemMatch. This query runs perfectly in shell.
      I have no clue how to translate it to C# as driver doesn't accept a filter without a name.
      I'm trying following code:

      Builders<BsonDocument>.Filter.ElemMatch ("Details.a", Builders<BsonDocument>.Filter.ElemMatch 
      (Builders<BsonDocument>.Filter.Regex(Builders<BsonDocument>.Filter.Regex
      ("DeviceName",new BsonRegularExpression("")))));
      

      No doubt, it didn't worked.
      I'm wondering if you guys have any plan to add support to driver to accept filters without name?

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

              Created:
              Updated: