title: Update mongoDB document in bulk in C#
body: <p>I have multiple document like below in mongo collection(giving just one sample).</p>
  <pre><code>{
      &quot;_id&quot;: &quot;5fdb&quot;,
      &quot;createddate&quot;: &quot;2020-12-17&quot;,
      &quot;orders&quot;: [
          {
              &quot;_id&quot;: &quot;4c65&quot;,
              &quot;sourcesystemrecordid&quot;: null,
              &quot;accepteddate&quot;: &quot;2020-12-19&quot;,
              &quot;fulfillment&quot;: [
                  {
                      &quot;_id&quot;: &quot;7d3ceb&quot;,
                      &quot;createdby&quot;: &quot;Azekry&quot;,
                      &quot;systemid&quot;: &quot;123&quot;,
                      &quot;systemrecordname&quot;: &quot;source1&quot;
                  }
              ]
          }
      ]
  }
  </code></pre>
  <p>Under fulfilment, I want to update &quot;<strong>systemid</strong>&quot; value from &quot;123&quot; to &quot;789&quot; for all the documents where &quot;systemrecordname&quot; = &quot;source1&quot; and for that I have written below piece of code but the data is not updated. Can you help me on this?</p>
  <pre><code>foreach (var item in resultFromDatabse)
                  {
                      var ordr = item.orders;
                      foreach (var e in ordr)
                      {
                          var actualval = &quot;789&quot;;
  
                          foreach (var ef in e.fulfillment.Where(x =&gt; x.systemrecordname == &quot;source1&quot;))
                          {
                              filter = builder.Eq(&quot;systemrecordname&quot;, ef.systemrecordname);
                              var update = Builders&lt;EquipmentDemandPlan&gt;.Update.Set(&quot;orders.$[e].fulfillment.$[ef].systemid&quot;, actualval);
  
                              UpdateOneModel&lt;EquipmentDemandPlan&gt; updateOne = new UpdateOneModel&lt;EquipmentDemandPlan&gt;(filter, update)
                              {
                                  ArrayFilters = new List&lt;ArrayFilterDefinition&gt; {
                                           new BsonDocumentArrayFilterDefinition&lt;BsonDocument&gt;(new BsonDocument(&quot;ef.systemrecordname&quot;, ef.systemrecordname))
                                      }
                              };
                              bulkupdate.Add(updateOne);
  
                          }
                      }
                  }
                  collection.BulkWriteAsync(bulkupdate);
  </code></pre>