QuaternaryList.AddIndex(string, Func) method¶
Defined in
Type: QuaternaryListReactiveList.Reactive.Collections
Assembly: ReactiveList.Reactive.dll
Applies to
net11.0, net10.0, net47, net471, net472, net48, net481
public void AddIndex<TIndexKey>(string indexName, Func<T, TIndexKey> keySelector) where TIndexKey : notnull
View source (opens in a new tab)
Summary: Adds a secondary index to enable efficient lookups based on a specified key selector.
Type parameters
| Name | Description |
|---|---|
TIndexKey | The type of the key used for indexing. |
Parameters
| Name | Type | Description |
|---|---|---|
indexName | string (opens in a new tab) | The unique name of the index to add. |
keySelector | Func | A function that extracts the key from each item for indexing. |
Remarks
The index is built and registered while every shard is write-locked, so no item is missed. An existing
index with the same name is replaced. If keySelector throws while the index is built, the index is not registered.
If it throws later, during a mutation, the mutation is still committed and announced, the index does not hold that item,
and the exception propagates to the caller after the change is complete.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException (opens in a new tab) | indexName or keySelector is null. |