title: Filter data from MongoDB with .NET driver
body: <p>I need to create a filter for my mongo collection filter. I'm using Mongo driver 2 for .NET.</p>
  
  <p>Here is my JSON.</p>
  
  <pre><code>[
      {
          "a": "val_a0",
          "b": "val_b0",
          "arr":[
              {
                  "c": "val_c0",
                  "d": "val_d0"
              },
              {
                  "c": "val_c1",
                  "d": "val_d1"
              },
              {
                  "c": "val_c2",
                  "d": "val_d2"
              }
          ]
      },
      {
          "a": "val_a1",
          "b": "val_b1",
          "arr":[
              {
                  "c": "val_c3",
                  "d": "val_d3"
              },
              {
                  "c": "val_c4",
                  "d": "val_d4"
              },
              {
                  "c": "val_c5",
                  "d": "val_d5"
              }
          ]
      },
  ...
  ]
  </code></pre>
  
  <p>I need to apply filter on root level property <code>a</code> and nested property <code>c</code>. My filter code is:-</p>
  
  <pre><code>public class MyFilterClass
  {
      public string a { get; set; }
  
      public MyFilterNestedClass nested { get; set; }
  }
  
  public class MyFilterNestedClass
  {
      public string c { get; set; }
  }
  </code></pre>
  
  <p>And filter code:-</p>
  
  <pre><code>public FilterDefinition&lt;MyClass&gt; Build(MyFilterClass filter)
  {
      var _filterDef = Builders&lt;MyClass&gt;.Filter.Empty;
  
      _filterDef &amp;= Builders&lt;MyClass&gt;.Filter.Eq(t =&gt; t.a, filter.a); // Filter by root level property [a]
  
      // Filter by nested level property [c]
      // First way
      _filterDef &amp;= Builders&lt;MyClass&gt;.Filter.Eq(t =&gt; t.arr.First(w =&gt; w.c == filter.MyFilterNestedClass.c).c, filter.arr.c);
  
      // Second way
      _filterDef &amp;= builders&lt;MyClass&gt;.filter.where(t =&gt; t.a == filter.a &amp;&amp;
                                                      t.arr.first(w =&gt; w.c == filter.MyFilterNestedClass.c) != null);
  
      return _filterDef;
  }
  </code></pre>
  
  <p>I tried using both the ways to apply nested property criteria. But it never returns any documents from database.</p>