Table of Contents

Class BsonValue

Namespace
MongoDB.Bson
Assembly
MongoDB.Bson.dll

Represents a BSON value (this is an abstract class, see the various subclasses).

[Serializable]
public abstract class BsonValue : IComparable<BsonValue>, IConvertible, IEquatable<BsonValue>
Inheritance
BsonValue
Implements
Derived
Inherited Members
Extension Methods

Properties

AsBoolean

Casts the BsonValue to a Boolean (throws an InvalidCastException if the cast is not valid).

public bool AsBoolean { get; }

Property Value

bool

AsBsonArray

Casts the BsonValue to a BsonArray (throws an InvalidCastException if the cast is not valid).

public BsonArray AsBsonArray { get; }

Property Value

BsonArray

AsBsonBinaryData

Casts the BsonValue to a BsonBinaryData (throws an InvalidCastException if the cast is not valid).

public BsonBinaryData AsBsonBinaryData { get; }

Property Value

BsonBinaryData

AsBsonDateTime

Casts the BsonValue to a BsonDateTime (throws an InvalidCastException if the cast is not valid).

public BsonDateTime AsBsonDateTime { get; }

Property Value

BsonDateTime

AsBsonDocument

Casts the BsonValue to a BsonDocument (throws an InvalidCastException if the cast is not valid).

public BsonDocument AsBsonDocument { get; }

Property Value

BsonDocument

AsBsonJavaScript

Casts the BsonValue to a BsonJavaScript (throws an InvalidCastException if the cast is not valid).

public BsonJavaScript AsBsonJavaScript { get; }

Property Value

BsonJavaScript

AsBsonJavaScriptWithScope

Casts the BsonValue to a BsonJavaScriptWithScope (throws an InvalidCastException if the cast is not valid).

public BsonJavaScriptWithScope AsBsonJavaScriptWithScope { get; }

Property Value

BsonJavaScriptWithScope

AsBsonMaxKey

Casts the BsonValue to a BsonMaxKey (throws an InvalidCastException if the cast is not valid).

public BsonMaxKey AsBsonMaxKey { get; }

Property Value

BsonMaxKey

AsBsonMinKey

Casts the BsonValue to a BsonMinKey (throws an InvalidCastException if the cast is not valid).

public BsonMinKey AsBsonMinKey { get; }

Property Value

BsonMinKey

AsBsonNull

Casts the BsonValue to a BsonNull (throws an InvalidCastException if the cast is not valid).

public BsonNull AsBsonNull { get; }

Property Value

BsonNull

AsBsonRegularExpression

Casts the BsonValue to a BsonRegularExpression (throws an InvalidCastException if the cast is not valid).

public BsonRegularExpression AsBsonRegularExpression { get; }

Property Value

BsonRegularExpression

AsBsonSymbol

Casts the BsonValue to a BsonSymbol (throws an InvalidCastException if the cast is not valid).

public BsonSymbol AsBsonSymbol { get; }

Property Value

BsonSymbol

AsBsonTimestamp

Casts the BsonValue to a BsonTimestamp (throws an InvalidCastException if the cast is not valid).

public BsonTimestamp AsBsonTimestamp { get; }

Property Value

BsonTimestamp

AsBsonUndefined

Casts the BsonValue to a BsonUndefined (throws an InvalidCastException if the cast is not valid).

public BsonUndefined AsBsonUndefined { get; }

Property Value

BsonUndefined

AsBsonValue

Casts the BsonValue to a BsonValue (a way of upcasting subclasses of BsonValue to BsonValue at compile time).

public BsonValue AsBsonValue { get; }

Property Value

BsonValue

AsByteArray

Casts the BsonValue to a Byte[] (throws an InvalidCastException if the cast is not valid).

public byte[] AsByteArray { get; }

Property Value

byte[]

AsDateTime

Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid).

[Obsolete("Use ToUniversalTime instead.")]
public DateTime AsDateTime { get; }

Property Value

DateTime

AsDecimal

Casts the BsonValue to a decimal (throws an InvalidCastException if the cast is not valid).

public decimal AsDecimal { get; }

Property Value

decimal

AsDecimal128

Casts the BsonValue to a Decimal128 (throws an InvalidCastException if the cast is not valid).

public Decimal128 AsDecimal128 { get; }

Property Value

Decimal128

AsDouble

Casts the BsonValue to a Double (throws an InvalidCastException if the cast is not valid).

public double AsDouble { get; }

Property Value

double

AsGuid

Casts the BsonValue to a Guid (throws an InvalidCastException if the cast is not valid).

public Guid AsGuid { get; }

Property Value

Guid

AsInt32

Casts the BsonValue to an Int32 (throws an InvalidCastException if the cast is not valid).

public int AsInt32 { get; }

Property Value

int

AsInt64

Casts the BsonValue to a Int64 (throws an InvalidCastException if the cast is not valid).

public long AsInt64 { get; }

Property Value

long

AsLocalTime

Casts the BsonValue to a DateTime in the local timezone (throws an InvalidCastException if the cast is not valid).

[Obsolete("Use ToLocalTime instead.")]
public DateTime AsLocalTime { get; }

Property Value

DateTime

AsNullableBoolean

Casts the BsonValue to a Nullable{Boolean} (throws an InvalidCastException if the cast is not valid).

public bool? AsNullableBoolean { get; }

Property Value

bool?

AsNullableDateTime

Casts the BsonValue to a Nullable{DateTime} (throws an InvalidCastException if the cast is not valid).

[Obsolete("Use ToNullableUniversalTime instead.")]
public DateTime? AsNullableDateTime { get; }

Property Value

DateTime?

AsNullableDecimal

Casts the BsonValue to a Nullable{Decimal} (throws an InvalidCastException if the cast is not valid).

public decimal? AsNullableDecimal { get; }

Property Value

decimal?

AsNullableDecimal128

Casts the BsonValue to a Nullable{Decimal128} (throws an InvalidCastException if the cast is not valid).

public Decimal128? AsNullableDecimal128 { get; }

Property Value

Decimal128?

AsNullableDouble

Casts the BsonValue to a Nullable{Double} (throws an InvalidCastException if the cast is not valid).

public double? AsNullableDouble { get; }

Property Value

double?

AsNullableGuid

Casts the BsonValue to a Nullable{Guid} (throws an InvalidCastException if the cast is not valid).

public Guid? AsNullableGuid { get; }

Property Value

Guid?

AsNullableInt32

Casts the BsonValue to a Nullable{Int32} (throws an InvalidCastException if the cast is not valid).

public int? AsNullableInt32 { get; }

Property Value

int?

AsNullableInt64

Casts the BsonValue to a Nullable{Int64} (throws an InvalidCastException if the cast is not valid).

public long? AsNullableInt64 { get; }

Property Value

long?

AsNullableObjectId

Casts the BsonValue to a Nullable{ObjectId} (throws an InvalidCastException if the cast is not valid).

public ObjectId? AsNullableObjectId { get; }

Property Value

ObjectId?

AsObjectId

Casts the BsonValue to an ObjectId (throws an InvalidCastException if the cast is not valid).

public ObjectId AsObjectId { get; }

Property Value

ObjectId

AsRegex

Casts the BsonValue to a Regex (throws an InvalidCastException if the cast is not valid).

public Regex AsRegex { get; }

Property Value

Regex

AsString

Casts the BsonValue to a String (throws an InvalidCastException if the cast is not valid).

public string AsString { get; }

Property Value

string

AsUniversalTime

Casts the BsonValue to a DateTime in UTC (throws an InvalidCastException if the cast is not valid).

[Obsolete("Use ToUniversalTime instead.")]
public DateTime AsUniversalTime { get; }

Property Value

DateTime

BsonType

Gets the BsonType of this BsonValue.

public abstract BsonType BsonType { get; }

Property Value

BsonType

IsBoolean

Tests whether this BsonValue is a Boolean.

public bool IsBoolean { get; }

Property Value

bool

IsBsonArray

Tests whether this BsonValue is a BsonArray.

public bool IsBsonArray { get; }

Property Value

bool

IsBsonBinaryData

Tests whether this BsonValue is a BsonBinaryData.

public bool IsBsonBinaryData { get; }

Property Value

bool

IsBsonDateTime

Tests whether this BsonValue is a BsonDateTime.

public bool IsBsonDateTime { get; }

Property Value

bool

IsBsonDocument

Tests whether this BsonValue is a BsonDocument.

public bool IsBsonDocument { get; }

Property Value

bool

IsBsonJavaScript

Tests whether this BsonValue is a BsonJavaScript.

public bool IsBsonJavaScript { get; }

Property Value

bool

IsBsonJavaScriptWithScope

Tests whether this BsonValue is a BsonJavaScriptWithScope.

public bool IsBsonJavaScriptWithScope { get; }

Property Value

bool

IsBsonMaxKey

Tests whether this BsonValue is a BsonMaxKey.

public bool IsBsonMaxKey { get; }

Property Value

bool

IsBsonMinKey

Tests whether this BsonValue is a BsonMinKey.

public bool IsBsonMinKey { get; }

Property Value

bool

IsBsonNull

Tests whether this BsonValue is a BsonNull.

public bool IsBsonNull { get; }

Property Value

bool

IsBsonRegularExpression

Tests whether this BsonValue is a BsonRegularExpression.

public bool IsBsonRegularExpression { get; }

Property Value

bool

IsBsonSymbol

Tests whether this BsonValue is a BsonSymbol .

public bool IsBsonSymbol { get; }

Property Value

bool

IsBsonTimestamp

Tests whether this BsonValue is a BsonTimestamp.

public bool IsBsonTimestamp { get; }

Property Value

bool

IsBsonUndefined

Tests whether this BsonValue is a BsonUndefined.

public bool IsBsonUndefined { get; }

Property Value

bool

IsDateTime

Tests whether this BsonValue is a DateTime.

[Obsolete("Use IsValidDateTime instead.")]
public bool IsDateTime { get; }

Property Value

bool

IsDecimal128

Tests whether this BsonValue is a Decimal128.

public bool IsDecimal128 { get; }

Property Value

bool

IsDouble

Tests whether this BsonValue is a Double.

public bool IsDouble { get; }

Property Value

bool

IsGuid

Tests whether this BsonValue is a Guid.

public bool IsGuid { get; }

Property Value

bool

IsInt32

Tests whether this BsonValue is an Int32.

public bool IsInt32 { get; }

Property Value

bool

IsInt64

Tests whether this BsonValue is an Int64.

public bool IsInt64 { get; }

Property Value

bool

IsNumeric

Tests whether this BsonValue is a numeric value.

public bool IsNumeric { get; }

Property Value

bool

IsObjectId

Tests whether this BsonValue is an ObjectId .

public bool IsObjectId { get; }

Property Value

bool

IsString

Tests whether this BsonValue is a String.

public bool IsString { get; }

Property Value

bool

IsValidDateTime

Tests whether this BsonValue is a valid DateTime.

public virtual bool IsValidDateTime { get; }

Property Value

bool

this[int]

Gets or sets a value by position (only applies to BsonDocument and BsonArray).

public virtual BsonValue this[int index] { get; set; }

Parameters

index int

The position.

Property Value

BsonValue

The value.

this[string]

Gets or sets a value by name (only applies to BsonDocument).

public virtual BsonValue this[string name] { get; set; }

Parameters

name string

The name.

Property Value

BsonValue

The value.

RawValue

Gets the raw value of this BsonValue (or null if this BsonValue doesn't have a single scalar value).

[Obsolete("Use Value property of subclasses or BsonTypeMapper.MapToDotNetValue instead.")]
public virtual object RawValue { get; }

Property Value

object

Methods

Clone()

Creates a shallow clone of the BsonValue (see also DeepClone).

public virtual BsonValue Clone()

Returns

BsonValue

A shallow clone of the BsonValue.

CompareTo(BsonValue)

Compares this BsonValue to another BsonValue.

public abstract int CompareTo(BsonValue other)

Parameters

other BsonValue

The other BsonValue.

Returns

int

A 32-bit signed integer that indicates whether this BsonValue is less than, equal to, or greather than the other BsonValue.

CompareTypeTo(BsonValue)

Compares the type of this BsonValue to the type of another BsonValue.

public int CompareTypeTo(BsonValue other)

Parameters

other BsonValue

The other BsonValue.

Returns

int

A 32-bit signed integer that indicates whether the type of this BsonValue is less than, equal to, or greather than the type of the other BsonValue.

Create(object)

Creates a new instance of the BsonValue class.

public static BsonValue Create(object value)

Parameters

value object

A value to be mapped to a BsonValue.

Returns

BsonValue

A BsonValue.

DeepClone()

Creates a deep clone of the BsonValue (see also Clone).

public virtual BsonValue DeepClone()

Returns

BsonValue

A deep clone of the BsonValue.

Equals(BsonValue)

Compares this BsonValue to another BsonValue.

public bool Equals(BsonValue rhs)

Parameters

rhs BsonValue

The other BsonValue.

Returns

bool

True if the two BsonValue values are equal.

Equals(object)

Compares this BsonValue to another object.

public override abstract bool Equals(object obj)

Parameters

obj object

The other object.

Returns

bool

True if the other object is a BsonValue and equal to this one.

GetHashCode()

Gets the hash code.

public override abstract int GetHashCode()

Returns

int

The hash code.

IConvertibleGetTypeCodeImplementation()

Implementation of the IConvertible GetTypeCode method.

protected virtual TypeCode IConvertibleGetTypeCodeImplementation()

Returns

TypeCode

The TypeCode.

IConvertibleToBooleanImplementation(IFormatProvider)

Implementation of the IConvertible ToBoolean method.

protected virtual bool IConvertibleToBooleanImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

bool

A bool.

IConvertibleToByteImplementation(IFormatProvider)

Implementation of the IConvertible ToByte method.

protected virtual byte IConvertibleToByteImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

byte

A byte.

IConvertibleToCharImplementation(IFormatProvider)

Implementation of the IConvertible ToChar method.

protected virtual char IConvertibleToCharImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

char

A char.

IConvertibleToDateTimeImplementation(IFormatProvider)

Implementation of the IConvertible ToDateTime method.

protected virtual DateTime IConvertibleToDateTimeImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

DateTime

A DateTime.

IConvertibleToDecimalImplementation(IFormatProvider)

Implementation of the IConvertible ToDecimal method.

protected virtual decimal IConvertibleToDecimalImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

decimal

A decimal.

IConvertibleToDoubleImplementation(IFormatProvider)

Implementation of the IConvertible ToDouble method.

protected virtual double IConvertibleToDoubleImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

double

A double.

IConvertibleToInt16Implementation(IFormatProvider)

Implementation of the IConvertible ToInt16 method.

protected virtual short IConvertibleToInt16Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

short

A short.

IConvertibleToInt32Implementation(IFormatProvider)

Implementation of the IConvertible ToInt32 method.

protected virtual int IConvertibleToInt32Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

int

An int.

IConvertibleToInt64Implementation(IFormatProvider)

Implementation of the IConvertible ToInt64 method.

protected virtual long IConvertibleToInt64Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

long

A long.

IConvertibleToSByteImplementation(IFormatProvider)

Implementation of the IConvertible ToSByte method.

protected virtual sbyte IConvertibleToSByteImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

sbyte

An sbyte.

IConvertibleToSingleImplementation(IFormatProvider)

Implementation of the IConvertible ToSingle method.

protected virtual float IConvertibleToSingleImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

float

A float.

IConvertibleToStringImplementation(IFormatProvider)

Implementation of the IConvertible ToString method.

protected virtual string IConvertibleToStringImplementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

string

A string.

IConvertibleToUInt16Implementation(IFormatProvider)

Implementation of the IConvertible ToUInt16 method.

protected virtual ushort IConvertibleToUInt16Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

ushort

A ushort.

IConvertibleToUInt32Implementation(IFormatProvider)

Implementation of the IConvertible ToUInt32 method.

protected virtual uint IConvertibleToUInt32Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

uint

A uint.

IConvertibleToUInt64Implementation(IFormatProvider)

Implementation of the IConvertible ToUInt64 method.

protected virtual ulong IConvertibleToUInt64Implementation(IFormatProvider provider)

Parameters

provider IFormatProvider

The format provider.

Returns

ulong

A ulong.

OperatorEqualsImplementation(BsonValue)

Implementation of operator ==.

protected virtual bool OperatorEqualsImplementation(BsonValue rhs)

Parameters

rhs BsonValue

The other BsonValue.

Returns

bool

True if the two BsonValues are equal according to ==.

ToBoolean()

Converts this BsonValue to a Boolean (using the JavaScript definition of truthiness).

public virtual bool ToBoolean()

Returns

bool

A Boolean.

ToDecimal()

Converts this BsonValue to a Decimal.

public virtual decimal ToDecimal()

Returns

decimal

A Decimal.

ToDecimal128()

Converts this BsonValue to a Decimal128.

public virtual Decimal128 ToDecimal128()

Returns

Decimal128

A Decimal128.

ToDouble()

Converts this BsonValue to a Double.

public virtual double ToDouble()

Returns

double

A Double.

ToInt32()

Converts this BsonValue to an Int32.

public virtual int ToInt32()

Returns

int

An Int32.

ToInt64()

Converts this BsonValue to an Int64.

public virtual long ToInt64()

Returns

long

An Int64.

ToLocalTime()

Converts this BsonValue to a DateTime in local time.

public virtual DateTime ToLocalTime()

Returns

DateTime

A DateTime.

ToNullableLocalTime()

Converts this BsonValue to a DateTime? in local time.

public virtual DateTime? ToNullableLocalTime()

Returns

DateTime?

A DateTime?.

ToNullableUniversalTime()

Converts this BsonValue to a DateTime? in UTC.

public virtual DateTime? ToNullableUniversalTime()

Returns

DateTime?

A DateTime?.

ToUniversalTime()

Converts this BsonValue to a DateTime in UTC.

public virtual DateTime ToUniversalTime()

Returns

DateTime

A DateTime.

Operators

operator ==(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator ==(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the two BsonValues are equal according to ==.

explicit operator Decimal128(BsonValue)

Casts a BsonValue to a Decimal128.

public static explicit operator Decimal128(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

Decimal128

A Decimal128.

explicit operator ObjectId(BsonValue)

Casts a BsonValue to an ObjectId.

public static explicit operator ObjectId(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

ObjectId

An ObjectId.

explicit operator bool(BsonValue)

Casts a BsonValue to a bool.

public static explicit operator bool(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

bool

A bool.

explicit operator byte[](BsonValue)

Casts a BsonValue to a byte[].

public static explicit operator byte[](BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

byte[]

A byte[].

explicit operator DateTime(BsonValue)

Casts a BsonValue to a DateTime.

public static explicit operator DateTime(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

DateTime

A DateTime.

explicit operator decimal(BsonValue)

Casts a BsonValue to a decimal.

public static explicit operator decimal(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

decimal

A decimal.

explicit operator double(BsonValue)

Casts a BsonValue to a double.

public static explicit operator double(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

double

A double.

explicit operator Guid(BsonValue)

Casts a BsonValue to a Guid.

public static explicit operator Guid(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

Guid

A Guid.

explicit operator int(BsonValue)

Casts a BsonValue to an int.

public static explicit operator int(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

int

An int.

explicit operator long(BsonValue)

Casts a BsonValue to a long.

public static explicit operator long(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

long

A long.

explicit operator Decimal128?(BsonValue)

Casts a BsonValue to a nullable Decimal128?.

public static explicit operator Decimal128?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

Decimal128?

A nullable Decimal128.

explicit operator ObjectId?(BsonValue)

Casts a BsonValue to an ObjectId?.

public static explicit operator ObjectId?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

ObjectId?

An ObjectId?.

explicit operator bool?(BsonValue)

Casts a BsonValue to a bool?.

public static explicit operator bool?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

bool?

A bool?.

explicit operator DateTime?(BsonValue)

Casts a BsonValue to a DateTime?.

public static explicit operator DateTime?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

DateTime?

A DateTime?.

explicit operator decimal?(BsonValue)

Casts a BsonValue to a decimal?.

public static explicit operator decimal?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

decimal?

A decimal?.

explicit operator double?(BsonValue)

Casts a BsonValue to a double?.

public static explicit operator double?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

double?

A double?.

explicit operator Guid?(BsonValue)

Casts a BsonValue to a Guid?.

public static explicit operator Guid?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

Guid?

A Guid?.

explicit operator int?(BsonValue)

Casts a BsonValue to an int?.

public static explicit operator int?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

int?

An int?.

explicit operator long?(BsonValue)

Casts a BsonValue to a long?.

public static explicit operator long?(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

long?

A long?.

explicit operator string(BsonValue)

Casts a BsonValue to a string.

public static explicit operator string(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

string

A string.

explicit operator Regex(BsonValue)

Casts a BsonValue to a Regex.

public static explicit operator Regex(BsonValue value)

Parameters

value BsonValue

The BsonValue.

Returns

Regex

A Regex.

operator >(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator >(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the first BsonValue is greater than the other one.

operator >=(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator >=(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the first BsonValue is greater than or equal to the other one.

implicit operator BsonValue(Decimal128)

Converts a Decimal128 to a BsonValue.

public static implicit operator BsonValue(Decimal128 value)

Parameters

value Decimal128

A Decimal128.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(ObjectId)

Converts an ObjectId to a BsonValue.

public static implicit operator BsonValue(ObjectId value)

Parameters

value ObjectId

An ObjectId.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(bool)

Converts a bool to a BsonValue.

public static implicit operator BsonValue(bool value)

Parameters

value bool

A bool.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(byte[])

Converts a byte[] to a BsonValue.

public static implicit operator BsonValue(byte[] value)

Parameters

value byte[]

A byte[].

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(DateTime)

Converts a DateTime to a BsonValue.

public static implicit operator BsonValue(DateTime value)

Parameters

value DateTime

A DateTime.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(decimal)

Converts a decimal to a BsonValue.

public static implicit operator BsonValue(decimal value)

Parameters

value decimal

A decimal.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(double)

Converts a double to a BsonValue.

public static implicit operator BsonValue(double value)

Parameters

value double

A double.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(Enum)

Converts an Enum to a BsonValue.

public static implicit operator BsonValue(Enum value)

Parameters

value Enum

An Enum.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(Guid)

Converts a Guid to a BsonValue.

[Obsolete("Use the BsonBinaryData constructor instead and specify a Guid representation.")]
public static implicit operator BsonValue(Guid value)

Parameters

value Guid

A Guid.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(int)

Converts an int to a BsonValue.

public static implicit operator BsonValue(int value)

Parameters

value int

An int.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(long)

Converts a long to a BsonValue.

public static implicit operator BsonValue(long value)

Parameters

value long

A long.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(Decimal128?)

Converts a nullable Decimal128 to a BsonValue.

public static implicit operator BsonValue(Decimal128? value)

Parameters

value Decimal128?

A Decimal128?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(ObjectId?)

Converts an ObjectId? to a BsonValue.

public static implicit operator BsonValue(ObjectId? value)

Parameters

value ObjectId?

An ObjectId?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(bool?)

Converts a bool? to a BsonValue.

public static implicit operator BsonValue(bool? value)

Parameters

value bool?

A bool?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(DateTime?)

Converts a DateTime? to a BsonValue.

public static implicit operator BsonValue(DateTime? value)

Parameters

value DateTime?

A DateTime?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(decimal?)

Converts a decimal? to a BsonValue.

public static implicit operator BsonValue(decimal? value)

Parameters

value decimal?

A decimal?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(double?)

Converts a double? to a BsonValue.

public static implicit operator BsonValue(double? value)

Parameters

value double?

A double?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(Guid?)

Converts a Guid? to a BsonValue.

[Obsolete("Use the BsonBinaryData constructor instead and specify a Guid representation.")]
public static implicit operator BsonValue(Guid? value)

Parameters

value Guid?

A Guid?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(int?)

Converts an int? to a BsonValue.

public static implicit operator BsonValue(int? value)

Parameters

value int?

An int?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(long?)

Converts a long? to a BsonValue.

public static implicit operator BsonValue(long? value)

Parameters

value long?

A long?.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(string)

Converts a string to a BsonValue.

public static implicit operator BsonValue(string value)

Parameters

value string

A string.

Returns

BsonValue

A BsonValue.

implicit operator BsonValue(Regex)

Converts a Regex to a BsonValue.

public static implicit operator BsonValue(Regex value)

Parameters

value Regex

A Regex.

Returns

BsonValue

A BsonValue.

operator !=(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator !=(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the two BsonValues are not equal according to ==.

operator <(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator <(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the first BsonValue is less than the other one.

operator <=(BsonValue, BsonValue)

Compares two BsonValues.

public static bool operator <=(BsonValue lhs, BsonValue rhs)

Parameters

lhs BsonValue

The first BsonValue.

rhs BsonValue

The other BsonValue.

Returns

bool

True if the first BsonValue is less than or equal to the other one.