Table of Contents

Method ToBsonDocument

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

ToBsonDocument<TNominalType>(TNominalType, IBsonSerializer<TNominalType>, Action<Builder>, BsonSerializationArgs)

Serializes an object to a BsonDocument.

public static BsonDocument ToBsonDocument<TNominalType>(this TNominalType obj, IBsonSerializer<TNominalType> serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)

Parameters

obj TNominalType

The object.

serializer IBsonSerializer<TNominalType>

The serializer.

configurator Action<BsonSerializationContext.Builder>

The serialization context configurator.

args BsonSerializationArgs

The serialization args.

Returns

BsonDocument

A BsonDocument.

Type Parameters

TNominalType

The nominal type of the object.

ToBsonDocument(object, Type, IBsonSerializer, Action<Builder>, BsonSerializationArgs)

Serializes an object to a BsonDocument.

public static BsonDocument ToBsonDocument(this object obj, Type nominalType, IBsonSerializer serializer = null, Action<BsonSerializationContext.Builder> configurator = null, BsonSerializationArgs args = default)

Parameters

obj object

The object.

nominalType Type

The nominal type of the object.

serializer IBsonSerializer

The serializer.

configurator Action<BsonSerializationContext.Builder>

The serialization context configurator.

args BsonSerializationArgs

The serialization args.

Returns

BsonDocument

A BsonDocument.

Exceptions

ArgumentNullException

nominalType

ArgumentException

serializer