Class BsonUtils
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
docBsonDocumentThe BSON document to search for the key.
keystringThe key of the value to retrieve.
Returns
- BsonValue
The MongoDB.Bson.BsonValue associated with
key, ornullif 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
valBsonValueThe MongoDB.Bson.BsonValue instance to convert to a CLR object.