Table of Contents

Method WithIndex

Namespace
MongoDB.Driver.Linq
Assembly
MongoDB.Driver.Legacy.dll

WithIndex<TSource>(IQueryable<TSource>, string)

Sets an index hint on the query that's being built.

public static IQueryable<TSource> WithIndex<TSource>(this IQueryable<TSource> source, string indexName)

Parameters

source IQueryable<TSource>

The query being built.

indexName string

The name of the index to use.

Returns

IQueryable<TSource>

New query where the expression includes a WithIndex method call.

Type Parameters

TSource

The type of the elements of source.

WithIndex<TSource>(IQueryable<TSource>, BsonDocument)

Sets an index hint on the query that's being built.

public static IQueryable<TSource> WithIndex<TSource>(this IQueryable<TSource> source, BsonDocument indexHint)

Parameters

source IQueryable<TSource>

The query being built.

indexHint BsonDocument

Hint for what index to use.

Returns

IQueryable<TSource>

New query where the expression includes a WithIndex method call.

Type Parameters

TSource

The type of the elements of source.