Class Index<T>
Represents an index creation command
TIP: Define the keys first with .Key() method and finally call the .Create() method.
Inheritance
Object
Index<T>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: MongoDB.Entities
Assembly: MongoDB.Entities.dll
Syntax
public class Index<T>
where T : IEntity
Type Parameters
Name | Description |
---|---|
T | Any class that implements IEntity |
Methods
CreateAsync(CancellationToken)
Call this method to finalize defining the index after setting the index keys and options.
Declaration
public async Task<string> CreateAsync(CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellation | An optional cancellation token |
Returns
Type | Description |
---|---|
Task<String> | The name of the created index |
DropAllAsync(CancellationToken)
Drops all indexes for this entity type
Declaration
public async Task DropAllAsync(CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellation | An optional cancellation token |
Returns
Type | Description |
---|---|
Task |
DropAsync(String, CancellationToken)
Drops an index by name for this entity type
Declaration
public async Task DropAsync(string name, CancellationToken cancellation = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the index to drop |
CancellationToken | cancellation | An optional cancellation token |
Returns
Type | Description |
---|---|
Task |
Key(Expression<Func<T, Object>>, KeyType)
Adds a key definition to the index
TIP: At least one key definition is required
Declaration
public Index<T> Key(Expression<Func<T, object>> propertyToIndex, KeyType type)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, Object>> | propertyToIndex | x => x.PropertyName |
KeyType | type | The type of the key |
Returns
Type | Description |
---|---|
Index<T> |
Option(Action<CreateIndexOptions<T>>)
Set the options for this index definition
TIP: Setting options is not required.
Declaration
public Index<T> Option(Action<CreateIndexOptions<T>> option)
Parameters
Type | Name | Description |
---|---|---|
Action<CreateIndexOptions<T>> | option | x => x.OptionName = OptionValue |
Returns
Type | Description |
---|---|
Index<T> |