title: How to update deeply nested array with C# MongoDB.Driver?
body: <p>I have such model:</p>
  
  <pre><code>{  
     "_id":"5b90eea8c02e062be2888446",
     "storeGuid":"e97d4730-9b8a-49ed-be87-caf4054439aa",
     "storeId":"0",
     "storeDbName":"0",
     "tenant":"dev",
     "configGroup":[  
        {  
           "groupName":"peopleCounter",
           "config":[  
              {  
                 "key":"averageWaitPeriodTime",
                 "value":"60",
              }
           ]
        },
        {  
           "groupName":"sessionMonitor",
           "config":[  
              {  
                 "key":"testKey1",
                 "value":"987",
              },
              {  
                 "key":"testKey2",
                 "value":"123",
              }
           ]
        }
     ]
  }
  </code></pre>
  
  <p>I am trying to update <code>value</code> for <code>"key":"testKey2"</code></p>
  
  <p>I have such update statement:</p>
  
  <pre><code>await coll.UpdateOneAsync(
      x =&gt; x.StoreGuid == storeGuid
           &amp;&amp; x.ConfigGroup.Any(y =&gt; y.GroupName == groupName
                                     &amp;&amp; y.Config.Any(z =&gt; z.Key == model.Key)),
      Builders&lt;StoreModel&gt;.Update.Set(x =&gt; x.ConfigGroup[-1].Config[-1].Value, model.Value));
  </code></pre>
  
  <p>When i try to update for example <code>groupName</code> using such filter <code>ConfigGroup[-1]</code> it works.</p>
  
  <p>But in the case when we have <code>ConfigGroup[-1].Config[-1]</code> it does not work.</p>
  
  <p>I know two options how to update the value:</p>
  
  <ul>
  <li>just update whole list using <code>ConfigGroup[-1].Config</code></li>
  <li>or specify concrete indexes for filter like <code>ConfigGroup[configGroupIndex].Config[configKeyIndex].Value</code></li>
  </ul>
  
  <p>But i want to know why it does not work with <code>-1</code> index.
  And how to do it properly.</p>
  
  <p>Please answer using <strong>c# MongoDB.Driver</strong>.</p>
  
  <p>Thanks in advance.</p>