title: Filter multiple parameters with MongoDB provider
body: <p>I have the below document schema.</p>
  
  <pre><code>{
        "name":"Name",
        "region":"New Jersey",
        "address":"92 Something Rd",
        "city":"Jersey City",
        "state":"NJ",
        "zipCode":"07302",
        "country":"USA",
        amenities":[
           "Sauna",
           "Locker",
           "Shop"
        ],
        "services":[
           "Car Rental",
           "Transportation"
        ]
  }
  </code></pre>
  
  <p>I want with one call to the server to get all the documents matching any of the filter arguments where map 1-1 meaning <code>"state" = "NJ" OR "city" = "Jersey City"</code> but also when any value of the list contained to any document array child, example <code>[ "Sauna", "Locker" ] ANY IN "amenities"</code>. And it should be an OR concatenation of all the possible filters. </p>
  
  <p>Using the C# MongoDB Driver I came up with the below methods so far in a <code>MongoRepository</code> class but doesn't return the desired results.</p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;T&gt;&gt; DocumentsMatchEqFieldValueAsync&lt;T&gt;(string collectionName,
              IDictionary&lt;string, string&gt; fieldsValues = null,
              IDictionary&lt;string, IEnumerable&lt;string&gt;&gt; fieldsWithEnumerableValues = null,
              IEnumerable&lt;ObjectId&gt; ids = null)
  {
      var cursor = await GetEqAsyncCursor&lt;T&gt;(collectionName, fieldsValues, fieldsWithEnumerableValues, ids).ConfigureAwait(false);
      return await cursor.ToListAsync().ConfigureAwait(false);
  }
  
  protected Task&lt;IAsyncCursor&lt;T&gt;&gt; GetEqAsyncCursor&lt;T&gt;(string collectionName, 
              IDictionary&lt;string, string&gt; fieldsValues = null,
              IDictionary&lt;string, IEnumerable&lt;string&gt;&gt; fieldsWithEnumerableValues = null,
              IEnumerable&lt;ObjectId&gt; ids = null)
  {
      var collection = GetCollection&lt;T&gt;(collectionName);
      var builder = Builders&lt;T&gt;.Filter;
  
      // Not sure if this is the correct way to initialize it because it seems adding an empty filter condition returning ALL document;
      FilterDefinition&lt;T&gt; filter = new BsonDocument(); 
  
      if (fieldsValues != null &amp;&amp;
          fieldsValues.Any())
      {
          filter = filter | fieldsValues
                      .Select(p =&gt; builder.Eq(p.Key, p.Value))
                      .Aggregate((p1, p2) =&gt; p1 | p2);
      }
  
      if (fieldsWithEnumerableValues != null &amp;&amp;
          fieldsWithEnumerableValues.Any())
      {
          filter = filter | fieldsWithEnumerableValues
                      .Select(p =&gt; builder.AnyEq(p.Key, p.Value))
                      .Aggregate((p1, p2) =&gt; p1 | p2);
      }
  
      if (ids != null &amp;&amp;
          ids.Any())
      {
          filter = filter | ids
                  .Select(p =&gt; builder.Eq("_id", p))
                  .Aggregate((p1, p2) =&gt; p1 | p2);
      }
      return collection.FindAsync(filter);
  }
  </code></pre>
  
  <p>I want it to be generic so the client can call the method like this.</p>
  
  <pre><code>public async Task should_return_any_records_matching_all_possible_criteria()
  {
      // Arrange
      IDocumentRepository documentRepository = new MongoRepository(_mongoConnectionString, _mongoDatabase);
  
      // Act
      var documents = await documentRepository.DocumentsMatchEqFieldValueAsync&lt;BsonDocument&gt;(Courses,
                  fieldsValues: new Dictionary&lt;string, string&gt;
                  {
                      { "state", "NJ" },
                      { "city", "Jersey City" }
                  },
                  fieldsWithEnumerableValues: new Dictionary&lt;string, IEnumerable&lt;string&gt;&gt;
                  {
                      { "services", new List&lt;string&gt; { "Car Rental", "Locker" } },
                      { "amenities", new List&lt;string&gt; { "Sauna", "Shop" } }
                  });
  
      // Assert
      documents.ShouldNotBeEmpty();
  }
  </code></pre>
  
  <p>I would expect documents that have <code>"state" = "NJ" OR "city" = "Jersey City" OR "services" CONTAINS ANY OF "Car Rental", "Locker" OR "amenities" CONTAINS ANY OF "Sauna", "Shop"</code>.</p>