title: MongoDB Linq nested Child Collection
body: <p>lets say I have this collection:</p>
  
  <pre><code>{
     "_id":"5d6d7333111acd18a0d0b383",
     "Bundle":{
        "_id":"5cf031c4abe00cbf4540f0b4",
        "Variations":[
           {
              "_id":"5cf031c37ea1d40960fd111f",
              "Code":"45A",
              "Label":"Modelo A",
              "Description":"",
              "VariationType":"A",
              "Summary":null,
              "Assets":[
                 {
                    "Asset":"ST_MT_1040_N",
                    "Price":"48000",
                    "CanBeExcluded":false
                 },
                 {
                    "Asset":"CP_IN_1015_A",
                    "Price":"84000",
                    "CanBeExcluded":false
                 }
              ]
           }
        ]
     }
  }
  </code></pre>
  
  <p>In c# I would like to list the collections that have a specific Asset code.</p>
  
  <pre><code>ex: Bundle.Variations[0].Assets.Asset
  </code></pre>
  
  <p>Variations is IEnumerable but ALLWAYS has only one object, so I get the .First()</p>
  
  <p>Some tries that I did:</p>
  
  <p><strong>FIRST TRY:</strong></p>
  
  <pre><code>    var builder = Builders&lt;ClientProject&gt;.Filter;
      var test1 = builder.Eq(!partnerId.IsNullOrWhiteSpace() ? "PartnerId" : "ClientId", clientId ?? partnerId)
                      &amp; builder.Gte(xx=&gt; (int)xx.Status, 7)
                      &amp; !builder.Eq(xx=&gt; (int)xx.Status, 90)
                      &amp; builder.Eq(xx=&gt; (int)xx.ProjectType, 0)
                      &amp; builder.Gte(xx=&gt; xx.StartedWithPoOn, from)
                      &amp; builder.Lte(xx=&gt; xx.StartedWithPoOn, to)
                      &amp; builder.ElemMatch(yy=&gt; yy.Bundle.Variations.First().Assets, assetCode);
  </code></pre>
  
  <p><strong>SECOND TRY:</strong></p>
  
  <pre><code>    var test2 = _coll.AsQueryable()
                          .Where(xx=&gt; (int)xx.Status &gt;= 7
                                          &amp;&amp; (int)xx.Status != 90
                                          &amp;&amp; (int)xx.ProjectType == 0
                                          &amp;&amp; xx.StartedWithPoOn &gt;= from
                                          &amp;&amp; xx.StartedWithPoOn &lt;= to
                                          &amp;&amp; xx.Bundle.Variations.First().Assets.Any(yy=&gt; yy.Asset == assetCode))
                          .ToList();
  </code></pre>
  
  <p>Both ways did not work at all!! </p>
  
  <p>Would have a LINQ way to return this or I would have to query Mongo diretcly using Aggreggtions with BsonDocuments? how would be? would have to use UnWind? projections?</p>