Table of Contents

Class QueryBuilder<TDocument>

Namespace
MongoDB.Driver.Builders
Assembly
MongoDB.Driver.Legacy.dll

Aids in building mongo queries based on type information.

public class QueryBuilder<TDocument>

Type Parameters

TDocument

The type of the document.

Inheritance
QueryBuilder<TDocument>
Inherited Members
Extension Methods

Constructors

QueryBuilder()

Initializes a new instance of the QueryBuilder<TDocument> class.

Methods

All<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Tests that the named array element contains all of the values (see $all).

And(params IMongoQuery[])

Tests that all the queries are true (see $and in newer versions of the server).

And(IEnumerable<IMongoQuery>)

Tests that all the queries are true (see $and in newer versions of the server).

BitsAllClear(Expression<Func<TDocument, object>>, long)

Tests that the value of the named element has all of the specified bits clear.

BitsAllSet(Expression<Func<TDocument, object>>, long)

Tests that the value of the named element has all of the specified bits set.

BitsAnyClear(Expression<Func<TDocument, object>>, long)

Tests that the value of the named element has any of the specified bits clear.

BitsAnySet(Expression<Func<TDocument, object>>, long)

Tests that the value of the named element has any of the specified bits set.

EQ<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that any of the values in the named array element is equal to some value.

EQ<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that the value of the named element is equal to some value.

ElemMatch<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, Func<QueryBuilder<TValue>, IMongoQuery>)

Tests that at least one item of the named array element matches a query (see $elemMatch).

Exists<TMember>(Expression<Func<TDocument, TMember>>)

Tests that an element of that name does or does not exist (see $exists).

GTE<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that any of the values in the named array element is greater than or equal to some value (see $gte).

GTE<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that the value of the named element is greater than or equal to some value (see $gte).

GT<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that any of the values in the named array element is greater than some value (see $lt).

GT<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that the value of the named element is greater than some value (see $gt).

GeoIntersects<TMember, TCoordinates>(Expression<Func<TDocument, TMember>>, GeoJsonGeometry<TCoordinates>)

Tests that a location element specified by name intersects with the geometry (see $geoIntersects).

In<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Tests that any of the values in the named array element are equal to one of a list of values (see $in).

In<TMember>(Expression<Func<TDocument, TMember>>, IEnumerable<TMember>)

Tests that the value of the named element is equal to one of a list of values (see $in).

LTE<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that any of the values in the named array element is less than or equal to some value (see $lte).

LTE<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that the value of the named element is less than or equal to some value (see $lte).

LT<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that any of the values in the named array element is less than some value (see $lt).

LT<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that the value of the named element is less than some value (see $lt).

Matches(Expression<Func<TDocument, IEnumerable<string>>>, BsonRegularExpression)

Tests that any of the values in the named array element matches a regular expression (see $regex).

Matches(Expression<Func<TDocument, string>>, BsonRegularExpression)

Tests that the value of the named element matches a regular expression (see $regex).

Mod(Expression<Func<TDocument, IEnumerable<int>>>, long, long)

Tests that the any of the values in the named array element match some value (see $mod).

Mod(Expression<Func<TDocument, int>>, long, long)

Tests that the modulus of the value of the named element matches some value (see $mod).

NE<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, TValue)

Tests that none of the values in the named array element is equal to some value (see $ne).

NE<TMember>(Expression<Func<TDocument, TMember>>, TMember)

Tests that an element does not equal the value (see $ne).

Near<TMember>(Expression<Func<TDocument, TMember>>, double, double)

Tests that the value of the named element is near some location (see $near).

Near<TMember>(Expression<Func<TDocument, TMember>>, double, double, double)

Tests that the value of the named element is near some location (see $near).

Near<TMember>(Expression<Func<TDocument, TMember>>, double, double, double, bool)

Tests that the value of the named element is near some location (see $near).

Near<TMember, TCoordinates>(Expression<Func<TDocument, TMember>>, GeoJsonPoint<TCoordinates>)

Tests that the value of the named element is near a point (see $near).

Near<TMember, TCoordinates>(Expression<Func<TDocument, TMember>>, GeoJsonPoint<TCoordinates>, double)

Tests that the value of the named element is near some location (see $near).

Near<TMember, TCoordinates>(Expression<Func<TDocument, TMember>>, GeoJsonPoint<TCoordinates>, double, bool)

Tests that the value of the named element is near some location (see $near).

Not(IMongoQuery)

Tests that the inverse of the query is true (see $not).

NotExists<TMember>(Expression<Func<TDocument, TMember>>)

Tests that an element of that name does not exist (see $exists).

NotIn<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, IEnumerable<TValue>)

Tests that the none of the values of the named array element is equal to any item in a list of values (see $nin).

NotIn<TMember>(Expression<Func<TDocument, TMember>>, IEnumerable<TMember>)

Tests that the value of the named element is not equal to any item in a list of values (see $nin).

Or(params IMongoQuery[])

Tests that at least one of the subqueries is true (see $or).

Or(IEnumerable<IMongoQuery>)

Tests that at least one of the subqueries is true (see $or).

Size<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, int)

Tests that the size of the named array is equal to some value (see $size).

Type<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, BsonType)

Tests that any of the values in the named array element is equal to some type (see $type).

Type<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, string)

Tests that any of the values in the named array element is equal to some type (see $type).

Type<TMember>(Expression<Func<TDocument, TMember>>, BsonType)

Tests that the type of the named element is equal to some type (see $type).

Type<TMember>(Expression<Func<TDocument, TMember>>, string)

Tests that the type of the named element is equal to some type (see $type).

Where(Expression<Func<TDocument, bool>>)

Builds a query from an expression.

WithinCircle<TMember>(Expression<Func<TDocument, TMember>>, double, double, double)

Tests that the value of the named element is within a circle (see $within and $center).

WithinCircle<TMember>(Expression<Func<TDocument, TMember>>, double, double, double, bool)

Tests that the value of the named element is within a circle (see $within and $center).

WithinPolygon<TMember>(Expression<Func<TDocument, TMember>>, double[,])

Tests that the value of the named element is within a polygon (see $within and $polygon).

WithinRectangle<TMember>(Expression<Func<TDocument, TMember>>, double, double, double, double)

Tests that the value of the named element is within a rectangle (see $within and $box).

Within<TMember, TCoordinates>(Expression<Func<TDocument, TMember>>, GeoJsonPolygon<TCoordinates>)

Tests that the value of the named element is within the specified geometry (see $within).