Creates a new index and adds it to the collection of indexes.

Namespace:  C1.LiveLinq.Indexing
Assembly:  C1.LiveLinq (in C1.LiveLinq.dll)

Syntax

C#
public IIndexScanner<T> Add(
	LambdaExpression keySelector,
	bool keyIsUnique,
	bool onlyOnce,
	IndexingAlgorithm algorithm,
	CultureInfo locale
)
Visual Basic
Public Function Add ( _
	keySelector As LambdaExpression, _
	keyIsUnique As Boolean, _
	onlyOnce As Boolean, _
	algorithm As IndexingAlgorithm, _
	locale As CultureInfo _
) As IIndexScanner(Of T)

Parameters

keySelector
Type: System.Linq.Expressions..::..LambdaExpression
Key selector expression of the index, see KeySelector.
keyIsUnique
Type: System..::..Boolean
Specifies whether the key used in this index is a unique key for the indexed collection (default: false).
onlyOnce
Type: System..::..Boolean
Specifies whether it is required that the index does not exist prior to this method call. If an index with this keySelector already exists, an exception is thrown if it is true, and this method call is ignored if it is false.
algorithm
Type: C1.LiveLinq.Indexing..::..IndexingAlgorithm
An IndexingAlgorithm used by the index. In the current version, only one algorithm is supported, RedBlackTree. Later versions may support other algorithms, such as bitmap or hash indexes.
locale
Type: System.Globalization..::..CultureInfo
Locale information used to compare strings in the index (default: CultureInfo.CurrentCulture).

Return Value

The new index added to the collection of indexes.

Remarks

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.

But do that only if you are sure that the key is indeed unique, as it imposes a uniqueness constraint on the indexed collection. An attempt to modify the indexed collection violating the uniqueness throws an InvalidOperationException.

See Also