Table of Contents

Method FindOneAs

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

FindOneAs<TDocument>()

Returns one document in this collection as a TDocument.

public virtual TDocument FindOneAs<TDocument>()

Returns

TDocument

A TDocument (or null if not found).

Type Parameters

TDocument

The type to deserialize the documents as.

FindOneAs<TDocument>(FindOneArgs)

Returns one document in this collection as a TDocument.

public virtual TDocument FindOneAs<TDocument>(FindOneArgs args)

Parameters

args FindOneArgs

The args.

Returns

TDocument

A TDocument (or null if not found).

Type Parameters

TDocument

The type of the document.

FindOneAs<TDocument>(IMongoQuery)

Returns one document in this collection that matches a query as a TDocument.

public virtual TDocument FindOneAs<TDocument>(IMongoQuery query)

Parameters

query IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

Returns

TDocument

A TDocument (or null if not found).

Type Parameters

TDocument

The type to deserialize the documents as.

FindOneAs(Type)

Returns one document in this collection as a TDocument.

public virtual object FindOneAs(Type documentType)

Parameters

documentType Type

The nominal type of the documents.

Returns

object

A document (or null if not found).

FindOneAs(Type, FindOneArgs)

Returns one document in this collection as a TDocument.

public virtual object FindOneAs(Type documentType, FindOneArgs args)

Parameters

documentType Type

The nominal type of the documents.

args FindOneArgs

The args.

Returns

object

A document (or null if not found).

FindOneAs(Type, IMongoQuery)

Returns one document in this collection that matches a query as a TDocument.

public virtual object FindOneAs(Type documentType, IMongoQuery query)

Parameters

documentType Type

The type to deserialize the documents as.

query IMongoQuery

The query (usually a QueryDocument or constructed using the Query builder).

Returns

object

A TDocument (or null if not found).