# C1.LiveLinq.Indexing.IndexDefinition-1.KeyIsUnique

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_LiveLinq_Indexing_IndexDefinition_1_KeyIsUnique_" data-uid="C1.LiveLinq.Indexing.IndexDefinition`1.KeyIsUnique*">KeyIsUnique Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_LiveLinq_Indexing_IndexDefinition_1_KeyIsUnique_" data-uid="C1.LiveLinq.Indexing.IndexDefinition`1.KeyIsUnique*"></a>
<h4 id="C1_LiveLinq_Indexing_IndexDefinition_1_KeyIsUnique" data-uid="C1.LiveLinq.Indexing.IndexDefinition`1.KeyIsUnique">KeyIsUnique</h4>
<div class="markdown level1 summary"><p>Gets a value that indicates whether the key used in this index is a unique key for the collection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public bool KeyIsUnique { get; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public ReadOnly Property KeyIsUnique As Boolean</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><p><b>true</b> if the key is unique; otherwise, <b>false</b></p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_LiveLinq_Indexing_IndexDefinition_1_KeyIsUnique_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>A unique index occupies less memory and performs better than a non-unique index (although the difference isn't dramatic).
Therefore, for unique keys, it's recommended to specify the corresponding index as unique in the
<a class="xref" href="C1.LiveLinq.Indexing.IndexCollection-1.Add.html#C1_LiveLinq_Indexing_IndexCollection_1_Add__1_System_Linq_Expressions_Expression_System_Func__0___0___">IndexCollection.Add</a> method.</p>
<p>But do that only if you are sure that the key is indeed unique, as it imposes a uniqueness constraint on the collection.
An attempt to modify the collection violating the uniqueness throws an <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.invalidoperationexception">InvalidOperationException</a>.</p>
</div>
</div>
