Class FieldsBuilder<TDocument>
A builder for specifying which fields of a document the server should return.
[Serializable]
[BsonSerializer(typeof(FieldsBuilder<>.Serializer))]
public class FieldsBuilder<TDocument> : BuilderBase, IConvertibleToBsonDocument, IMongoFields
Type Parameters
TDocument
The type of the document.
- Inheritance
-
FieldsBuilder<TDocument>
- Implements
- Inherited Members
- Extension Methods
Constructors
FieldsBuilder()
Initializes a new instance of the FieldsBuilder class.
public FieldsBuilder()
Methods
ElemMatch<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, Func<QueryBuilder<TValue>, IMongoQuery>)
Returns the first matching element in the array specified by name.
public FieldsBuilder<TDocument> ElemMatch<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, Func<QueryBuilder<TValue>, IMongoQuery> elementQueryBuilderFunction)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
elementQueryBuilderFunction
Func<QueryBuilder<TValue>, IMongoQuery>The element query builder function.
Returns
- FieldsBuilder<TDocument>
The build (so method calls can be chained).
Type Parameters
TValue
The type of the value.
Exclude(params Expression<Func<TDocument, object>>[])
Adds one or more field names to be excluded from the results.
public FieldsBuilder<TDocument> Exclude(params Expression<Func<TDocument, object>>[] memberExpressions)
Parameters
memberExpressions
Expression<Func<TDocument, object>>[]The member expressions.
Returns
- FieldsBuilder<TDocument>
The builder (so method calls can be chained).
Include(params Expression<Func<TDocument, object>>[])
Adds one or more field names to be included in the results.
public FieldsBuilder<TDocument> Include(params Expression<Func<TDocument, object>>[] memberExpressions)
Parameters
memberExpressions
Expression<Func<TDocument, object>>[]The member expressions.
Returns
- FieldsBuilder<TDocument>
The builder (so method calls can be chained).
MetaTextScore(Expression<Func<TDocument, object>>)
Specifies the name of field to hold the computed relevance score for text search.
public FieldsBuilder<TDocument> MetaTextScore(Expression<Func<TDocument, object>> memberExpression)
Parameters
memberExpression
Expression<Func<TDocument, object>>The member expression specifying the field to hold the computed relevance score.
Returns
- FieldsBuilder<TDocument>
The builder (so method calls can be chained).
Slice<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, int)
Adds a slice to be included in the results.
public FieldsBuilder<TDocument> Slice<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, int size)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
size
intThe size of the slice (negative sizes are taken from the end).
Returns
- FieldsBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
Slice<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>>, int, int)
Adds a slice to be included in the results.
public FieldsBuilder<TDocument> Slice<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, int skip, int limit)
Parameters
memberExpression
Expression<Func<TDocument, IEnumerable<TValue>>>The member expression.
skip
intThe number of values to skip.
limit
intThe number of values to extract.
Returns
- FieldsBuilder<TDocument>
The builder (so method calls can be chained).
Type Parameters
TValue
The type of the enumerable member values.
ToBsonDocument()
Converts this object to a BsonDocument.
public override BsonDocument ToBsonDocument()
Returns
- BsonDocument
A BsonDocument.