# C1.Data.ClientScope.AddRef

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Data_ClientScope_AddRef_" data-uid="C1.Data.ClientScope.AddRef*">AddRef Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Data_ClientScope_AddRef_" data-uid="C1.Data.ClientScope.AddRef*"></a>
<h4 id="C1_Data_ClientScope_AddRef_System_Object_" data-uid="C1.Data.ClientScope.AddRef(System.Object)">AddRef(object)</h4>
<div class="markdown level1 summary"><p>Marks an entity as needed. Needed entities are not detached/released from the context
until the client scope is disposed.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddRef(object entity)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddRef(entity As Object)</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.object">object</a></td>
      <td><span class="parametername">entity</span></td>
      <td><p>An entity to be marked as needed.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Data_ClientScope_AddRef_System_Object__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Client views and C1DataSource classes mark entities as needed automatically. Use this method only when you fetch entities using other means,
bypassing Studio for EF classes with direct access to the underlying object context.
When you no longer need those entities, call <a class="xref" href="C1.Data.ClientScope.Release.html#C1_Data_ClientScope_Release_System_Object_">Release(object)</a>.
AddRef and Release are counting, every AddRef call must be balanced by a Release call.</p>
</div>


<a id="C1_Data_ClientScope_AddRef_" data-uid="C1.Data.ClientScope.AddRef*"></a>
<h4 id="C1_Data_ClientScope_AddRef_System_Type_" data-uid="C1.Data.ClientScope.AddRef(System.Type)">AddRef(Type)</h4>
<div class="markdown level1 summary"><p>Mark all entities of a given type as needed. All entities of that type will not be detached from the context until the client scope is disposed.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void AddRef(Type entityType)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub AddRef(entityType As Type)</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.type">Type</a></td>
      <td><span class="parametername">entityType</span></td>
      <td><p>An entity type to mark as needed.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
