Table of Contents

Class FieldsBuilder

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

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

[Serializable]
[BsonSerializer(typeof(FieldsBuilder.Serializer))]
public class FieldsBuilder : BuilderBase, IConvertibleToBsonDocument, IMongoFields
Inheritance
FieldsBuilder
Implements
Inherited Members
Extension Methods

Constructors

FieldsBuilder()

Initializes a new instance of the FieldsBuilder class.

public FieldsBuilder()

Methods

ElemMatch(string, IMongoQuery)

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

public FieldsBuilder ElemMatch(string name, IMongoQuery query)

Parameters

name string

The name.

query IMongoQuery

The query.

Returns

FieldsBuilder

The build (so method calls can be chained).

Exclude(params string[])

Adds one or more field names to be excluded from the results.

public FieldsBuilder Exclude(params string[] names)

Parameters

names string[]

One or more field names.

Returns

FieldsBuilder

The builder (so method calls can be chained).

Include(params string[])

Adds one or more field names to be included in the results.

public FieldsBuilder Include(params string[] names)

Parameters

names string[]

One or more field names.

Returns

FieldsBuilder

The builder (so method calls can be chained).

MetaTextScore(string)

Specifies the name of field to hold the computed relevance score for text search.

public FieldsBuilder MetaTextScore(string name)

Parameters

name string

The name of the field to hold the computed relevance score.

Returns

FieldsBuilder

The builder (so method calls can be chained).

Slice(string, int)

Adds a slice to be included in the results.

public FieldsBuilder Slice(string name, int size)

Parameters

name string

The name of the field to slice.

size int

The size of the slice (negative sizes are taken from the end).

Returns

FieldsBuilder

The builder (so method calls can be chained).

Slice(string, int, int)

Adds a slice to be included in the results.

public FieldsBuilder Slice(string name, int skip, int limit)

Parameters

name string

The name of the field to slice.

skip int

The number of values to skip.

limit int

The number of values to extract.

Returns

FieldsBuilder

The builder (so method calls can be chained).

ToBsonDocument()

Returns the result of the builder as a BsonDocument.

public override BsonDocument ToBsonDocument()

Returns

BsonDocument

A BsonDocument.