Class Index<T>
Represents an index creation command
TIP: Define the keys first with .Key() method and finally call the .InitAsync() method.
public class Index<T> where T : IEntity
Type Parameters
TAny class that implements IEntity
- Inheritance
-
Index<T>
- Inherited Members
Constructors
Index(DB)
Represents an index creation command
TIP: Define the keys first with .Key() method and finally call the .InitAsync() method.
public Index(DB db)
Parameters
dbDB
Methods
CreateAsync(CancellationToken)
Call this method to finalize defining the index after setting the index keys and options.
public Task<string> CreateAsync(CancellationToken cancellation = default)
Parameters
cancellationCancellationTokenAn optional cancellation token
Returns
DropAllAsync(CancellationToken)
Drops all indexes for this entity type
public Task DropAllAsync(CancellationToken cancellation = default)
Parameters
cancellationCancellationTokenAn optional cancellation token
Returns
DropAsync(string, CancellationToken)
Drops an index by name for this entity type
public Task DropAsync(string name, CancellationToken cancellation = default)
Parameters
namestringThe name of the index to drop
cancellationCancellationTokenAn optional cancellation token
Returns
Key(Expression<Func<T, object?>>, KeyType)
Adds a key definition to the index
TIP: At least one key definition is required
public Index<T> Key(Expression<Func<T, object?>> propertyToIndex, KeyType type)
Parameters
propertyToIndexExpression<Func<T, object>>x => x.PropertyName
typeKeyTypeThe type of the key
Returns
- Index<T>
Option(Action<CreateIndexOptions<T>>)
Set the options for this index definition
TIP: Setting options is not required.
public Index<T> Option(Action<CreateIndexOptions<T>> option)
Parameters
optionAction<CreateIndexOptions<T>>x => x.OptionName = OptionValue
Returns
- Index<T>