# C1.Data.ClientScope

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_Data_ClientScope" data-uid="C1.Data.ClientScope" class="text-break">ClientScope Class
</h1>
  <div class="markdown level0 summary"><p>Defines a scope of data access. Provides facilities to create <a class="xref" href="C1.Data.ClientView-1.html">client views</a>.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">ClientScope</span></div>
      <div class="level2"><a class="xref" href="C1.Data.Entities.EntityClientScope.html">EntityClientScope</a></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.Data.html">C1.Data</a></h6>
  <h6><strong>Assembly</strong>: C1.Data.Entity.4.8.dll</h6>
  <h5 id="C1_Data_ClientScope_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class ClientScope : IDisposable</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class ClientScope
    Implements IDisposable</code></pre>
  </div>
  <h5 id="C1_Data_ClientScope_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><p>
Usually, one scope is created per form/window.
Entities <a class="xref" href="C1.Data.ClientScope.AddRef.html#C1_Data_ClientScope_AddRef_System_Object_">pinned to the scope (marked as needed)</a> are not evicted from the cache 
until the scope is <a class="xref" href="C1.Data.ClientScope.Dispose.html#C1_Data_ClientScope_Dispose">disposed</a> or collected by the garbage collector.
</p>
<p>
This class is a base class for platform-specific scopes, such as C1.Data.Entities.EntityClientCache (Entity Framework)
and C1.Silverlight.Data.RiaServices.RiaClientCache (RIA Services).
</p>
</div>
  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Data_ClientScope__ctor_C1_Data_ClientCacheBase_" data-uid="C1.Data.ClientScope.#ctor(C1.Data.ClientCacheBase)">
          <a class="xref" href="C1.Data.ClientScope.-ctor.html#C1_Data_ClientScope__ctor_C1_Data_ClientCacheBase_">ClientScope(ClientCacheBase)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of <a class="xref" href="C1.Data.ClientScope.html">ClientScope</a> class with the given <a class="xref" href="C1.Data.ClientCacheBase.html">ClientCacheBase</a>.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Data_ClientScope_ClientCache" data-uid="C1.Data.ClientScope.ClientCache">
          <a class="xref" href="C1.Data.ClientScope.ClientCache.html#C1_Data_ClientScope_ClientCache">ClientCache</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the <a class="xref" href="C1.Data.ClientCacheBase.html">ClientCacheBase</a> to which this <a class="xref" href="C1.Data.ClientScope.html">client scope</a> is connected.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Data_ClientScope_AddRef_System_Object_" data-uid="C1.Data.ClientScope.AddRef(System.Object)">
          <a class="xref" href="C1.Data.ClientScope.AddRef.html#C1_Data_ClientScope_AddRef_System_Object_">AddRef(object)</a>
        </td>
        <td 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>
</td>
      </tr>
      <tr>
        <td id="C1_Data_ClientScope_AddRef_System_Type_" data-uid="C1.Data.ClientScope.AddRef(System.Type)">
          <a class="xref" href="C1.Data.ClientScope.AddRef.html#C1_Data_ClientScope_AddRef_System_Type_">AddRef(Type)</a>
        </td>
        <td 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>
</td>
      </tr>
      <tr>
        <td id="C1_Data_ClientScope_Dispose" data-uid="C1.Data.ClientScope.Dispose">
          <a class="xref" href="C1.Data.ClientScope.Dispose.html#C1_Data_ClientScope_Dispose">Dispose()</a>
        </td>
        <td class="markdown level1 summary"><p>Marks the scope as disposed. Entities that were marked needed by a disposed scope may be disposed of (evicted from the cache, detached from context)
unless they are needed by other active scopes.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Data_ClientScope_Release_System_Object_" data-uid="C1.Data.ClientScope.Release(System.Object)">
          <a class="xref" href="C1.Data.ClientScope.Release.html#C1_Data_ClientScope_Release_System_Object_">Release(object)</a>
        </td>
        <td class="markdown level1 summary"><p>Unmark a needed entity.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Data_ClientScope_Release_System_Type_" data-uid="C1.Data.ClientScope.Release(System.Type)">
          <a class="xref" href="C1.Data.ClientScope.Release.html#C1_Data_ClientScope_Release_System_Type_">Release(Type)</a>
        </td>
        <td class="markdown level1 summary"><p>Unmark a needed entity type. Calling this method does not release memory.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
