Table of Contents

Method FindOneByIdAs

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

FindOneByIdAs<TDocument>(BsonValue)

Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.

public virtual TDocument FindOneByIdAs<TDocument>(BsonValue id)

Parameters

id BsonValue

The id of the document.

Returns

TDocument

A TDocument (or null if not found).

Type Parameters

TDocument

The nominal type of the document.

FindOneByIdAs(Type, BsonValue)

Returns a cursor that can be used to find one document in this collection by its _id value as a TDocument.

public virtual object FindOneByIdAs(Type documentType, BsonValue id)

Parameters

documentType Type

The nominal type of the document.

id BsonValue

The id of the document.

Returns

object

A TDocument (or null if not found).