Table of Contents

Method ElemMatch

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

ElemMatch<TDocument, TItem>(ProjectionDefinition<TDocument>, FieldDefinition<TDocument>, FilterDefinition<TItem>)

Combines an existing projection with a projection that filters the contents of an array.

public static ProjectionDefinition<TDocument> ElemMatch<TDocument, TItem>(this ProjectionDefinition<TDocument> projection, FieldDefinition<TDocument> field, FilterDefinition<TItem> filter)

Parameters

projection ProjectionDefinition<TDocument>

The projection.

field FieldDefinition<TDocument>

The field.

filter FilterDefinition<TItem>

The filter.

Returns

ProjectionDefinition<TDocument>

A combined projection.

Type Parameters

TDocument

The type of the document.

TItem

The type of the item.

ElemMatch<TDocument, TItem>(ProjectionDefinition<TDocument>, Expression<Func<TDocument, IEnumerable<TItem>>>, FilterDefinition<TItem>)

Combines an existing projection with a projection that filters the contents of an array.

public static ProjectionDefinition<TDocument> ElemMatch<TDocument, TItem>(this ProjectionDefinition<TDocument> projection, Expression<Func<TDocument, IEnumerable<TItem>>> field, FilterDefinition<TItem> filter)

Parameters

projection ProjectionDefinition<TDocument>

The projection.

field Expression<Func<TDocument, IEnumerable<TItem>>>

The field.

filter FilterDefinition<TItem>

The filter.

Returns

ProjectionDefinition<TDocument>

A combined projection.

Type Parameters

TDocument

The type of the document.

TItem

The type of the item.

ElemMatch<TDocument, TItem>(ProjectionDefinition<TDocument>, Expression<Func<TDocument, IEnumerable<TItem>>>, Expression<Func<TItem, bool>>)

Combines an existing projection with a projection that filters the contents of an array.

public static ProjectionDefinition<TDocument> ElemMatch<TDocument, TItem>(this ProjectionDefinition<TDocument> projection, Expression<Func<TDocument, IEnumerable<TItem>>> field, Expression<Func<TItem, bool>> filter)

Parameters

projection ProjectionDefinition<TDocument>

The projection.

field Expression<Func<TDocument, IEnumerable<TItem>>>

The field.

filter Expression<Func<TItem, bool>>

The filter.

Returns

ProjectionDefinition<TDocument>

A combined projection.

Type Parameters

TDocument

The type of the document.

TItem

The type of the item.