Table of Contents

Class BsonUtils

Namespace
adas_core.Domain.Utils
Assembly
adas-core.Domain.dll

Provides static utility methods for working with BSON (Binary JSON) data.

public static class BsonUtils
Inheritance
BsonUtils
Inherited Members

Methods

Get(BsonDocument, string)

Gets the value associated with the specified key from the BSON document, returning null if the key is not found.

public static BsonValue? Get(this BsonDocument doc, string key)

Parameters

doc BsonDocument

The BSON document to search for the key.

key string

The key of the value to retrieve.

Returns

BsonValue

The MongoDB.Bson.BsonValue associated with key, or null if the key does not exist.

ToObject(BsonValue)

Converts a MongoDB.Bson.BsonValue to a corresponding common language runtime (CLR) scalar object, supporting int, long, double, DateTime (normalized to UTC), and string values.

public static object? ToObject(this BsonValue val)

Parameters

val BsonValue

The MongoDB.Bson.BsonValue instance to convert to a CLR object.

Returns

object

The underlying CLR value when val is an Int32, Int64, Double, valid DateTime (in UTC), or String; otherwise null.