# C1.Data.ClientCacheBase.BulkChanges

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Data_ClientCacheBase_BulkChanges_" data-uid="C1.Data.ClientCacheBase.BulkChanges*">BulkChanges Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Data_ClientCacheBase_BulkChanges_" data-uid="C1.Data.ClientCacheBase.BulkChanges*"></a>
<h4 id="C1_Data_ClientCacheBase_BulkChanges_System_Action_" data-uid="C1.Data.ClientCacheBase.BulkChanges(System.Action)">BulkChanges(Action)</h4>
<div class="markdown level1 summary"><p>Used to group massive changes to entities and to allow manual explicit changes of entity states.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void BulkChanges(Action makeChanges)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub BulkChanges(makeChanges As Action)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.action">Action</a></td>
      <td><span class="parametername">makeChanges</span></td>
      <td><p>A delegate that makes changes in entities.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Data_ClientCacheBase_BulkChanges_System_Action__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>
Internal state of the client-side cache and all existing <a class="xref" href="C1.Data.ClientView-1.html">client views</a> based on the cache
are kept unchanged, aren't updated while the given <code class="paramref">makeChanges</code> is executed.
After the delegate completes its execution (having modified multiple entities),
the client-side cache internal state is restored and client views
are updated (maintained) to reflect the changes made in entities during the delegate's execution.
</p>
<p>There are two main scenarios where you should consider calling this method:</p>
<ol><li>
Using this method when you make a lot of changes to entities can improve performance 
because the change processing is deferred, occurs only once after all changes are done instead of every time on each change.
Depending on the amount of changes, the speedup can be considerable.
</li><li>
You must use this method when you need to make changes to entity states by calling any of the following methods:
<ul><li>System.Data.Objects.ObjectStateEntry.ChangeState/SetModified/AcceptChanges,</li><li>System.Data.Objects.ObjectContext.AcceptAllChanges,</li><li>System.ServiceModel.DomainServices.Client.DomainContext.RejectChanges,</li><li>System.ServiceModel.DomainServices.Client.Entity.AcceptChanges/RejectChanges,</li><li>System.ServiceModel.DomainServices.Client.EntitySet.AcceptChanges/RejectChanges,</li><li>System.Windows.Controls.DomainDataSource.RejectChanges.</li></ul>
</li></ol>
Calling these methods without wrapping them with <a class="xref" href="C1.Data.ClientCacheBase.BulkChanges.html#C1_Data_ClientCacheBase_BulkChanges_System_Action_">BulkChanges(Action)</a> can corrupt the client-side cache.
</div>
<h5 id="C1_Data_ClientCacheBase_BulkChanges_System_Action__examples">Examples</h5>
<pre><code class="lang-csharp">var scope = clientCache.CreateScope();
clientCache.BulkChanges(delegate {
    foreach(var detail in scope.GetItems&lt;Order_Details&gt;)
        detail.Discount *= 2;
});</code></pre>

</div>
