Table of Contents

Method ElemMatch

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

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

Creates an element match filter for an array field.

public FilterDefinition<TDocument> ElemMatch<TItem>(FieldDefinition<TDocument> field, FilterDefinition<TItem> filter)

Parameters

field FieldDefinition<TDocument>

The field.

filter FilterDefinition<TItem>

The filter.

Returns

FilterDefinition<TDocument>

An element match filter.

Type Parameters

TItem

The type of the item.

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

Creates an element match filter for an array field.

public FilterDefinition<TDocument> ElemMatch<TItem>(Expression<Func<TDocument, IEnumerable<TItem>>> field, FilterDefinition<TItem> filter)

Parameters

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

The field.

filter FilterDefinition<TItem>

The filter.

Returns

FilterDefinition<TDocument>

An element match filter.

Type Parameters

TItem

The type of the item.

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

Creates an element match filter for an array field.

public FilterDefinition<TDocument> ElemMatch<TItem>(Expression<Func<TDocument, IEnumerable<TItem>>> field, Expression<Func<TItem, bool>> filter)

Parameters

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

The field.

filter Expression<Func<TItem, bool>>

The filter.

Returns

FilterDefinition<TDocument>

An element match filter.

Type Parameters

TItem

The type of the item.