title: Mongo update array element (.NET driver 2.0)
body: <p>EDIT:
  Not looking for the javascript way of doing this. I am looking for the MongoDB C# 2.0 driver way of doing this (I know it might not be possible; but I hope somebody knows a solution).</p>
  
  <p>I am trying to update the value of an item embedded in an array on the primary document in my mongodb.</p>
  
  <p>I am looking for a strongly typed way to do this. I am using the <a href="http://mongodb.github.io/mongo-csharp-driver/2.0/" rel="noreferrer">Mongodb c# 2.0 driver</a></p>
  
  <p>I can do it by popping the element, updating the value, then reinserting. This just doesn't feel right; since I am overwriting what might have been written in the meantime.</p>
  
  <p>Here is what I have tried so far but with no luck:</p>
  
  <pre><code>private readonly IMongoCollection&lt;TempAgenda&gt; _collection;
  
  void Main()
  {
      var collectionName = "Agenda";
      var client = new MongoClient("mongodb://localhost:27017");
      var db = client.GetDatabase("Test");
      _collection = db.GetCollection&lt;TempAgenda&gt;(collectionName);
      UpdateItemTitle(1, 1, "hello");
  }
  
  public void UpdateItemTitle(string agendaId, string itemId, string title){
      var filter = Builders&lt;TempAgenda&gt;.Filter.Eq(x =&gt; x.AgendaId, agendaId);
      var update = Builders&lt;TempAgenda&gt;.Update.Set(x =&gt; x.Items.Single(p =&gt; p.Id.Equals(itemId)).Title, title);
      var result = _collection.UpdateOneAsync(filter, update).Result;
  }
  </code></pre>