title: How to find and update an item inside of a array (of an object in an array) {Accounts[x].Items[y].StatusCode = ...}
body: <p>I have a simple nested array (below). My goal is to represent these items in C# as 'Account' objects that contain a list of 'Item' along with the other account info. I can set up this structure just time in MongoDB but I have no idea how to update the StatusCode on a single item on a single account.</p>
  
  <pre><code>{  
     "Accounts":[  
        {  
           "Name":"SomeName1",
           "Email":"email1@site.com",
           "OwnedItems":[  
              {  
                 "ItemId":55,
                 "StatusCode":1
              },
              {  
                 "ItemId":12,
                 "StatusCode":2
              }
           ]
        },
        {  
           "Name":"SomeName2",
           "Email":"email2@site.com",
           "OwnedItems":[  
              {  
                 "ItemId":100,
                 "StatusCode":3
              },
              {  
                 "ItemId":101,
                 "StatusCode":4
              }
           ]
        }
     ]
  }
  </code></pre>
  
  <p>My question is how would I query to find and update a specific StatusCode in with this setup?</p>
  
  <p>Essentially what I want to do is the following. Of course, this following code would not actually update the DB.</p>
  
  <pre><code>public void Update_StatusCode(string accountName, int itemId, int newStatusCode)
  {
      var foundAccount = collection.Find(Builders&lt;AccountSave&gt;.Filter.Eq(acc =&gt; acc.Name, accountName)).FirstOrDefaultAsync().Result;
      foreach (var item in foundAccount.OwnedItems)
      {
          if (item.ItemId == itemId)
              item.StatusCode = newStatusCode;
      }
  }
  </code></pre>
  
  <p>Edit: To clarify, I am using the 2.0 driver. Also, yes I know there are no '_id's. Being an example, assume they are used properly.</p>