Table of Contents

Class ReadPreference

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Core.dll

Represents a read preference.

public sealed class ReadPreference : IEquatable<ReadPreference>
Inheritance
ReadPreference
Implements
Inherited Members

Constructors

ReadPreference(ReadPreferenceMode, IEnumerable<TagSet>, TimeSpan?, ReadPreferenceHedge)

Initializes a new instance of the ReadPreference class.

public ReadPreference(ReadPreferenceMode mode, IEnumerable<TagSet> tagSets = null, TimeSpan? maxStaleness = null, ReadPreferenceHedge hedge = null)

Parameters

mode ReadPreferenceMode

The read preference mode.

tagSets IEnumerable<TagSet>

The tag sets.

maxStaleness TimeSpan?

The maximum staleness.

hedge ReadPreferenceHedge

The hedge.

Properties

Hedge

Gets the hedge.

public ReadPreferenceHedge Hedge { get; }

Property Value

ReadPreferenceHedge

MaxStaleness

Gets the maximum staleness.

public TimeSpan? MaxStaleness { get; }

Property Value

TimeSpan?

The maximum staleness.

Nearest

Gets an instance of ReadPreference that represents a Nearest read preference.

public static ReadPreference Nearest { get; }

Property Value

ReadPreference

An instance of ReadPreference that represents a Nearest read preference.

Primary

Gets an instance of ReadPreference that represents a Primary read preference.

public static ReadPreference Primary { get; }

Property Value

ReadPreference

An instance of ReadPreference that represents a Primary read preference.

PrimaryPreferred

Gets an instance of ReadPreference that represents a PrimaryPreferred read preference.

public static ReadPreference PrimaryPreferred { get; }

Property Value

ReadPreference

An instance of ReadPreference that represents a PrimaryPreferred read preference.

ReadPreferenceMode

Gets the read preference mode.

public ReadPreferenceMode ReadPreferenceMode { get; }

Property Value

ReadPreferenceMode

The read preference mode.

Secondary

Gets an instance of ReadPreference that represents a Secondary read preference.

public static ReadPreference Secondary { get; }

Property Value

ReadPreference

An instance of ReadPreference that represents a Secondary read preference.

SecondaryPreferred

Gets an instance of ReadPreference that represents a SecondaryPreferred read preference.

public static ReadPreference SecondaryPreferred { get; }

Property Value

ReadPreference

An instance of ReadPreference that represents a SecondaryPreferred read preference.

TagSets

Gets the tag sets.

public IReadOnlyList<TagSet> TagSets { get; }

Property Value

IReadOnlyList<TagSet>

The tag sets.

Methods

Equals(ReadPreference)

public bool Equals(ReadPreference other)

Parameters

other ReadPreference

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

FromBsonDocument(BsonDocument)

Creates a new ReadPreference instance from a BsonDocument.

public static ReadPreference FromBsonDocument(BsonDocument document)

Parameters

document BsonDocument

The document.

Returns

ReadPreference

A ReadPreference.

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

With(ReadPreferenceHedge)

Returns a new instance of ReadPreference with some values changed.

public ReadPreference With(ReadPreferenceHedge hedge)

Parameters

hedge ReadPreferenceHedge

The hedge.

Returns

ReadPreference

A new instance of ReadPreference.

With(ReadPreferenceMode)

Returns a new instance of ReadPreference with some values changed.

public ReadPreference With(ReadPreferenceMode mode)

Parameters

mode ReadPreferenceMode

The read preference mode.

Returns

ReadPreference

A new instance of ReadPreference.

With(IEnumerable<TagSet>)

Returns a new instance of ReadPreference with some values changed.

public ReadPreference With(IEnumerable<TagSet> tagSets)

Parameters

tagSets IEnumerable<TagSet>

The tag sets.

Returns

ReadPreference

A new instance of ReadPreference.

With(TimeSpan?)

Returns a new instance of ReadPreference with some values changed.

public ReadPreference With(TimeSpan? maxStaleness)

Parameters

maxStaleness TimeSpan?

The maximum staleness.

Returns

ReadPreference

A new instance of ReadPreference.