Table of Contents

Class LinqToMongo

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

This static class holds methods that can be used to express MongoDB specific query operations in LINQ queries.

public static class LinqToMongo
Inheritance
LinqToMongo
Inherited Members

Methods

ContainsAll<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

Determines whether a sequence contains all of the specified values.

public static bool ContainsAll<TSource>(this IEnumerable<TSource> source, IEnumerable<TSource> values)

Parameters

source IEnumerable<TSource>

A sequence in which to locate the values.

values IEnumerable<TSource>

The values to locate in the sequence.

Returns

bool

True if the sequence contains all of the specified values.

Type Parameters

TSource

The type of the elements of source.

ContainsAny<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)

Determines whether a sequence contains any of the specified values.

public static bool ContainsAny<TSource>(this IEnumerable<TSource> source, IEnumerable<TSource> values)

Parameters

source IEnumerable<TSource>

A sequence in which to locate the values.

values IEnumerable<TSource>

The values to locate in the sequence.

Returns

bool

True if the sequence contains any of the specified values.

Type Parameters

TSource

The type of the elements of source.

In<TSource>(TSource, IEnumerable<TSource>)

Determines whether a specified value is contained in a sequence.

public static bool In<TSource>(this TSource value, IEnumerable<TSource> source)

Parameters

value TSource

The value to locate in the sequence.

source IEnumerable<TSource>

A sequence in which to locate the values.

Returns

bool

True if the value is contained in the sequence.

Type Parameters

TSource

The type of the elements of source.

Inject(IMongoQuery)

Injects a low level IMongoQuery into a LINQ where clause. Can only be used in LINQ queries.

public static bool Inject(this IMongoQuery query)

Parameters

query IMongoQuery

The low level query.

Returns

bool

Throws an InvalidOperationException if called.

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.

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.