Table of Contents

Class MongoDBRef

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Represents a DBRef (a convenient way to refer to a document).

[BsonSerializer(typeof(MongoDBRefSerializer))]
public class MongoDBRef : IEquatable<MongoDBRef>
Inheritance
MongoDBRef
Implements
Inherited Members

Constructors

MongoDBRef(string, BsonValue)

Creates a MongoDBRef.

public MongoDBRef(string collectionName, BsonValue id)

Parameters

collectionName string

The name of the collection that contains the document.

id BsonValue

The Id of the document.

MongoDBRef(string, string, BsonValue)

Creates a MongoDBRef.

public MongoDBRef(string databaseName, string collectionName, BsonValue id)

Parameters

databaseName string

The name of the database that contains the document.

collectionName string

The name of the collection that contains the document.

id BsonValue

The Id of the document.

Properties

CollectionName

Gets the name of the collection that contains the document.

public string CollectionName { get; }

Property Value

string

DatabaseName

Gets the name of the database that contains the document.

public string DatabaseName { get; }

Property Value

string

Id

Gets the Id of the document.

public BsonValue Id { get; }

Property Value

BsonValue

Methods

Equals(MongoDBRef)

Determines whether this instance and another specified MongoDBRef object have the same value.

public bool Equals(MongoDBRef rhs)

Parameters

rhs MongoDBRef

The MongoDBRef object to compare to this instance.

Returns

bool

True if the value of the rhs parameter is the same as this instance; otherwise, false.

Equals(MongoDBRef, MongoDBRef)

Determines whether two specified MongoDBRef objects have the same value.

public static bool Equals(MongoDBRef lhs, MongoDBRef rhs)

Parameters

lhs MongoDBRef

The first value to compare, or null.

rhs MongoDBRef

The second value to compare, or null.

Returns

bool

True if the value of lhs is the same as the value of rhs; otherwise, false.

Equals(object)

Determines whether this instance and a specified object, which must also be a MongoDBRef object, have the same value.

public override bool Equals(object obj)

Parameters

obj object

The MongoDBRef object to compare to this instance.

Returns

bool

True if obj is a MongoDBRef object and its value is the same as this instance; otherwise, false.

GetHashCode()

Returns the hash code for this MongoDBRef object.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

ToString()

Returns a string representation of the value.

public override string ToString()

Returns

string

A string representation of the value.

Operators

operator ==(MongoDBRef, MongoDBRef)

Determines whether two specified MongoDBRef objects have the same value.

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

Parameters

lhs MongoDBRef

The first value to compare, or null.

rhs MongoDBRef

The second value to compare, or null.

Returns

bool

True if the value of lhs is the same as the value of rhs; otherwise, false.

operator !=(MongoDBRef, MongoDBRef)

Determines whether two specified MongoDBRef objects have different values.

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

Parameters

lhs MongoDBRef

The first value to compare, or null.

rhs MongoDBRef

The second value to compare, or null.

Returns

bool

True if the value of lhs is different from the value of rhs; otherwise, false.