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

Support $all filters with more Contains methods

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.2
    • Affects Version/s: 2.19.1
    • Component/s: LINQ3
    • Labels:
      None
    • Fully Compatible
    • Not 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?

      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?

      The following pattern:

       

      values.All(e => document.A.Contains(e)) // where values is a constant array
      

      is translated to the filter:

       

       

      { A : { $all : [<values>] } }
      

      This is true of both LINQ2 and LINQ3.

       

      However, LINQ3 currently only supports this pattern if the Contains method resolves to Enumerable.Contains. We need to support other Contains methods, for example ICollection.Contains.

      Instead of looking for specific Contains methods (there are many), we can see if the Contains method "looks" like a Contains method:

      1. Is named "Contains"
      2. Return type is bool
      3. Has two parameters (call them source and value)
      4. Source implements IEnumerable<TItem>
      5. value is assignable to TItem

      The Contains method could be either a static or an instance method:

      • if static, source is the first argument and value is the second
      • if instance, source is the object itself and value is the only argument

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

              Created:
              Updated:
              Resolved: