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

Support for $elemMatch filters directly against the elements with no field name

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: 2.2.3
    • Component/s: Linq
    • None
    • Environment:
      Windows, Mac, C#, MongoDB 3.2, C# Driver 2.2.3 and earlier.
    • Fully Compatible
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Depending on what documentation we already have for `FilterDefinitionBuilder.ElemMatch` we may want to document the new overload.

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to? Depending on what documentation we already have for `FilterDefinitionBuilder.ElemMatch` we may want to document the new overload.

      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:
              Resolved: