Table of Contents

Class Fields<TDocument>

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

A builder for specifying which fields of a document the server should return.

public static class Fields<TDocument>

Type Parameters

TDocument

The type of the document.

Inheritance
Fields<TDocument>
Inherited Members

Properties

Null

Gets a null value with a type of IMongoFields.

public static IMongoFields Null { get; }

Property Value

IMongoFields

Methods

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

Returns the first matching element in the array specified by name.

public static 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 static 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 static 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 static 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 static FieldsBuilder<TDocument> Slice<TValue>(Expression<Func<TDocument, IEnumerable<TValue>>> memberExpression, int size)

Parameters

memberExpression Expression<Func<TDocument, IEnumerable<TValue>>>

The member expression.

size int

The 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 static 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 int

The number of values to skip.

limit int

The 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.