Class Query
A builder for creating queries.
public static class Query
- Inheritance
-
Query
- Inherited Members
Properties
Empty
Gets an empty query.
public static IMongoQuery Empty { get; }
Property Value
- IMongoQuery
An empty query.
Null
Gets a null value with a type of IMongoQuery.
public static IMongoQuery Null { get; }
Property Value
Methods
All(string, IEnumerable<BsonValue>)
Tests that the named array element contains all of the values (see $all).
public static IMongoQuery All(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the element to test.
values
IEnumerable<BsonValue>The values to compare to.
Returns
- IMongoQuery
An IMongoQuery.
And(params IMongoQuery[])
Tests that all the queries are true (see $and in newer versions of the server).
public static IMongoQuery And(params IMongoQuery[] queries)
Parameters
queries
IMongoQuery[]A list of subqueries.
Returns
- IMongoQuery
An IMongoQuery.
And(IEnumerable<IMongoQuery>)
Tests that all the queries are true (see $and in newer versions of the server).
public static IMongoQuery And(IEnumerable<IMongoQuery> queries)
Parameters
queries
IEnumerable<IMongoQuery>A list of subqueries.
Returns
- IMongoQuery
An IMongoQuery.
BitsAllClear(string, long)
Tests that the value of the named element has all of the specified bits clear.
public static IMongoQuery BitsAllClear(string name, long bitmask)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
BitsAllSet(string, long)
Tests that the value of the named element has all of the specified bits set.
public static IMongoQuery BitsAllSet(string name, long bitmask)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
BitsAnyClear(string, long)
Tests that the value of the named element has any of the specified bits clear.
public static IMongoQuery BitsAnyClear(string name, long bitmask)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
BitsAnySet(string, long)
Tests that the value of the named element has any of the specified bits set.
public static IMongoQuery BitsAnySet(string name, long bitmask)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Create(BsonDocument)
Creates a query manually.
public static IMongoQuery Create(BsonDocument query)
Parameters
query
BsonDocumentThe query.
Returns
- IMongoQuery
An IMongoQuery.
Create(string, BsonValue)
Creates a query manually.
public static IMongoQuery Create(string name, BsonValue condition)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
EQ(string, BsonValue)
Tests that the value of the named element is equal to some value.
public static IMongoQuery EQ(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
ElemMatch(string, IMongoQuery)
Tests that at least one item of the named array element matches a query (see $elemMatch).
public static IMongoQuery ElemMatch(string name, IMongoQuery query)
Parameters
name
stringThe name of the element to test.
query
IMongoQueryThe query to match elements with.
Returns
- IMongoQuery
An IMongoQuery.
Exists(string)
Tests that an element of that name exists (see $exists).
public static IMongoQuery Exists(string name)
Parameters
name
stringThe name of the element to test.
Returns
- IMongoQuery
An IMongoQuery.
GT(string, BsonValue)
Tests that the value of the named element is greater than some value (see $gt).
public static IMongoQuery GT(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
GTE(string, BsonValue)
Tests that the value of the named element is greater than or equal to some value (see $gte).
public static IMongoQuery GTE(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
GeoIntersects<TCoordinates>(string, GeoJsonGeometry<TCoordinates>)
Tests that a location element specified by name intersects with the geometry (see $geoIntersects).
public static IMongoQuery GeoIntersects<TCoordinates>(string name, GeoJsonGeometry<TCoordinates> geometry) where TCoordinates : GeoJsonCoordinates
Parameters
name
stringThe name.
geometry
GeoJsonGeometry<TCoordinates>The geometry.
Returns
- IMongoQuery
An IMongoQuery.
Type Parameters
TCoordinates
The type of the coordinates.
In(string, IEnumerable<BsonValue>)
Tests that the value of the named element is equal to one of a list of values (see $in).
public static IMongoQuery In(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the element to test.
values
IEnumerable<BsonValue>The values to compare to.
Returns
- IMongoQuery
An IMongoQuery.
LT(string, BsonValue)
Tests that the value of the named element is less than some value (see $lt).
public static IMongoQuery LT(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
LTE(string, BsonValue)
Tests that the value of the named element is less than or equal to some value (see $lte).
public static IMongoQuery LTE(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Matches(string, BsonRegularExpression)
Tests that the value of the named element matches a regular expression (see $regex).
public static IMongoQuery Matches(string name, BsonRegularExpression regex)
Parameters
name
stringThe name of the element to test.
regex
BsonRegularExpressionThe regex.
Returns
- IMongoQuery
An IMongoQuery.
Mod(string, long, long)
Tests that the modulus of the value of the named element matches some value (see $mod).
public static IMongoQuery Mod(string name, long modulus, long value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
NE(string, BsonValue)
Tests that an element does not equal the value (see $ne).
public static IMongoQuery NE(string name, BsonValue value)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Near(string, double, double)
Tests that the value of the named element is near some location (see $near).
public static IMongoQuery Near(string name, double x, double y)
Parameters
name
stringThe name of the element to test.
x
doubleThe x value of the origin.
y
doubleThe y value of the origin.
Returns
- IMongoQuery
An IMongoQuery.
Near(string, double, double, double)
Tests that the value of the named element is near some location (see $near).
public static IMongoQuery Near(string name, double x, double y, double maxDistance)
Parameters
name
stringThe name of the element to test.
x
doubleThe x value of the origin.
y
doubleThe y value of the origin.
maxDistance
doubleThe max distance.
Returns
- IMongoQuery
An IMongoQuery.
Near(string, double, double, double, bool)
Tests that the value of the named element is near some location (see $near).
public static IMongoQuery Near(string name, double x, double y, double maxDistance, bool spherical)
Parameters
name
stringThe name of the element to test.
x
doubleThe x value of the origin.
y
doubleThe y value of the origin.
maxDistance
doubleThe max distance.
spherical
boolif set to
true
then the query will be translated to $nearSphere.
Returns
- IMongoQuery
An IMongoQuery.
Near<TCoordinates>(string, GeoJsonPoint<TCoordinates>)
Tests that the value of the named element is near a point (see $near).
public static IMongoQuery Near<TCoordinates>(string name, GeoJsonPoint<TCoordinates> point) where TCoordinates : GeoJsonCoordinates
Parameters
name
stringThe name of the element to test.
point
GeoJsonPoint<TCoordinates>The point.
Returns
- IMongoQuery
An IMongoQuery.
Type Parameters
TCoordinates
The type of the coordinates.
Near<TCoordinates>(string, GeoJsonPoint<TCoordinates>, double)
Tests that the value of the named element is near some location (see $near).
public static IMongoQuery Near<TCoordinates>(string name, GeoJsonPoint<TCoordinates> point, double maxDistance) where TCoordinates : GeoJsonCoordinates
Parameters
name
stringThe name of the element to test.
point
GeoJsonPoint<TCoordinates>The point.
maxDistance
doubleThe max distance.
Returns
- IMongoQuery
An IMongoQuery.
Type Parameters
TCoordinates
The type of the coordinates.
Near<TCoordinates>(string, GeoJsonPoint<TCoordinates>, double, bool)
Tests that the value of the named element is near some location (see $near).
public static IMongoQuery Near<TCoordinates>(string name, GeoJsonPoint<TCoordinates> point, double maxDistance, bool spherical) where TCoordinates : GeoJsonCoordinates
Parameters
name
stringThe name of the element to test.
point
GeoJsonPoint<TCoordinates>The point.
maxDistance
doubleThe max distance.
spherical
boolif set to
true
then the query will be translated to $nearSphere.
Returns
- IMongoQuery
An IMongoQuery.
Type Parameters
TCoordinates
The type of the coordinates.
Not(IMongoQuery)
Tests that the inverse of the query is true (see $not).
public static IMongoQuery Not(IMongoQuery query)
Parameters
query
IMongoQueryThe query.
Returns
- IMongoQuery
An IMongoQuery.
NotExists(string)
Tests that an element of that name does not exist (see $exists).
public static IMongoQuery NotExists(string name)
Parameters
name
stringThe name of the element to test.
Returns
- IMongoQuery
An IMongoQuery.
NotIn(string, IEnumerable<BsonValue>)
Tests that the value of the named element is not equal to any item in a list of values (see $nin).
public static IMongoQuery NotIn(string name, IEnumerable<BsonValue> values)
Parameters
name
stringThe name of the element to test.
values
IEnumerable<BsonValue>The values to compare.
Returns
- IMongoQuery
An IMongoQuery.
Or(params IMongoQuery[])
Tests that at least one of the subqueries is true (see $or).
public static IMongoQuery Or(params IMongoQuery[] queries)
Parameters
queries
IMongoQuery[]The subqueries.
Returns
- IMongoQuery
An IMongoQuery.
Or(IEnumerable<IMongoQuery>)
Tests that at least one of the subqueries is true (see $or).
public static IMongoQuery Or(IEnumerable<IMongoQuery> queries)
Parameters
queries
IEnumerable<IMongoQuery>The subqueries.
Returns
- IMongoQuery
An IMongoQuery.
Size(string, int)
Tests that the size of the named array is equal to some value (see $size).
public static IMongoQuery Size(string name, int size)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
SizeGreaterThan(string, int)
Tests that the size of the named array is greater than some value.
public static IMongoQuery SizeGreaterThan(string name, int size)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
SizeGreaterThanOrEqual(string, int)
Tests that the size of the named array is greater than or equal to some value.
public static IMongoQuery SizeGreaterThanOrEqual(string name, int size)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
SizeLessThan(string, int)
Tests that the size of the named array is less than some value.
public static IMongoQuery SizeLessThan(string name, int size)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
SizeLessThanOrEqual(string, int)
Tests that the size of the named array is less than or equal to some value.
public static IMongoQuery SizeLessThanOrEqual(string name, int size)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Text(string)
Generate a text search query that tests whether the given search string is present.
public static IMongoQuery Text(string searchString)
Parameters
searchString
stringThe search string.
Returns
- IMongoQuery
An IMongoQuery that represents the text search.
Text(string, TextSearchOptions)
Generate a text search query that tests whether the given search string is present using the specified language's rules. Specifies use of language appropriate stop words, stemming rules etc.
public static IMongoQuery Text(string searchString, TextSearchOptions options)
Parameters
searchString
stringThe search string.
options
TextSearchOptionsThe text search options.
Returns
- IMongoQuery
An IMongoQuery that represents the text search for the particular language.
Text(string, string)
Generate a text search query that tests whether the given search string is present using the specified language's rules. Specifies use of language appropriate stop words, stemming rules etc.
public static IMongoQuery Text(string searchString, string language)
Parameters
Returns
- IMongoQuery
An IMongoQuery that represents the text search for the particular language.
Type(string, BsonType)
Tests that the type of the named element is equal to some type (see $type).
public static IMongoQuery Type(string name, BsonType type)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Type(string, string)
Tests that the type of the named element is equal to some type (see $type).
public static IMongoQuery Type(string name, string type)
Parameters
Returns
- IMongoQuery
An IMongoQuery.
Where(BsonJavaScript)
Tests that a JavaScript expression is true (see $where).
public static IMongoQuery Where(BsonJavaScript javascript)
Parameters
javascript
BsonJavaScriptThe javascript.
Returns
- IMongoQuery
An IMongoQuery.
WithinCircle(string, double, double, double)
Tests that the value of the named element is within a circle (see $within and $center).
public static IMongoQuery WithinCircle(string name, double centerX, double centerY, double radius)
Parameters
name
stringThe name of the element to test.
centerX
doubleThe x coordinate of the origin.
centerY
doubleThe y coordinate of the origin.
radius
doubleThe radius of the circle.
Returns
- IMongoQuery
An IMongoQuery.
WithinCircle(string, double, double, double, bool)
Tests that the value of the named element is within a circle (see $within and $center).
public static IMongoQuery WithinCircle(string name, double centerX, double centerY, double radius, bool spherical)
Parameters
name
stringThe name of the element to test.
centerX
doubleThe x coordinate of the origin.
centerY
doubleThe y coordinate of the origin.
radius
doubleThe radius of the circle.
spherical
boolif set to
true
[spherical].
Returns
- IMongoQuery
An IMongoQuery.
WithinPolygon(string, double[,])
Tests that the value of the named element is within a polygon (see $within and $polygon).
public static IMongoQuery WithinPolygon(string name, double[,] points)
Parameters
name
stringThe name of the element to test.
points
double[,]An array of points that defines the polygon (the second dimension must be of length 2).
Returns
- IMongoQuery
An IMongoQuery.
WithinRectangle(string, double, double, double, double)
Tests that the value of the named element is within a rectangle (see $within and $box).
public static IMongoQuery WithinRectangle(string name, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY)
Parameters
name
stringThe name of the element to test.
lowerLeftX
doubleThe x coordinate of the lower left corner.
lowerLeftY
doubleThe y coordinate of the lower left corner.
upperRightX
doubleThe x coordinate of the upper right corner.
upperRightY
doubleThe y coordinate of the upper right corner.
Returns
- IMongoQuery
An IMongoQuery.
Within<TCoordinates>(string, GeoJsonPolygon<TCoordinates>)
Tests that the value of the named element is within the specified geometry (see $within).
public static IMongoQuery Within<TCoordinates>(string name, GeoJsonPolygon<TCoordinates> polygon) where TCoordinates : GeoJsonCoordinates
Parameters
name
stringThe name of the element to test.
polygon
GeoJsonPolygon<TCoordinates>The polygon.
Returns
- IMongoQuery
An IMongoQuery.
Type Parameters
TCoordinates
The type of the coordinates.