Table of Contents

Class MongoClientSettings

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

The settings for a MongoDB client.

public class MongoClientSettings : IEquatable<MongoClientSettings>
Inheritance
MongoClientSettings
Implements
Inherited Members

Constructors

MongoClientSettings()

Creates a new instance of MongoClientSettings. Usually you would use a connection string instead.

public MongoClientSettings()

Properties

AllowInsecureTls

Gets or sets whether to relax TLS constraints as much as possible. Setting this variable to true will also set SslSettings.CheckCertificateRevocation to false.

public bool AllowInsecureTls { get; set; }

Property Value

bool

ApplicationName

Gets or sets the application name.

public string ApplicationName { get; set; }

Property Value

string

AutoEncryptionOptions

Gets or sets the auto encryption options.

public AutoEncryptionOptions AutoEncryptionOptions { get; set; }

Property Value

AutoEncryptionOptions

ClusterConfigurator

Gets or sets the cluster configurator.

public Action<ClusterBuilder> ClusterConfigurator { get; set; }

Property Value

Action<ClusterBuilder>

Compressors

Gets or sets the compressors.

public IReadOnlyList<CompressorConfiguration> Compressors { get; set; }

Property Value

IReadOnlyList<CompressorConfiguration>

ConnectTimeout

Gets or sets the connect timeout.

public TimeSpan ConnectTimeout { get; set; }

Property Value

TimeSpan

ConnectionMode

Gets or sets the connection mode.

[Obsolete("Use DirectConnection instead.")]
public ConnectionMode ConnectionMode { get; set; }

Property Value

ConnectionMode

ConnectionModeSwitch

Gets the connection mode switch.

[Obsolete("This property will be removed in a later release.")]
public ConnectionModeSwitch ConnectionModeSwitch { get; }

Property Value

ConnectionModeSwitch

Credential

Gets or sets the credential.

public MongoCredential Credential { get; set; }

Property Value

MongoCredential

Credentials

Gets or sets the credentials.

[Obsolete("Use Credential instead. Using multiple credentials is deprecated.")]
public IEnumerable<MongoCredential> Credentials { get; set; }

Property Value

IEnumerable<MongoCredential>

DirectConnection

Gets or sets the direct connection.

public bool? DirectConnection { get; set; }

Property Value

bool?

GuidRepresentation

Gets or sets the representation to use for Guids.

[Obsolete("Configure serializers instead.")]
public GuidRepresentation GuidRepresentation { get; set; }

Property Value

GuidRepresentation

HeartbeatInterval

Gets or sets the heartbeat interval.

public TimeSpan HeartbeatInterval { get; set; }

Property Value

TimeSpan

HeartbeatTimeout

Gets or sets the heartbeat timeout.

public TimeSpan HeartbeatTimeout { get; set; }

Property Value

TimeSpan

IPv6

Gets or sets a value indicating whether to use IPv6.

public bool IPv6 { get; set; }

Property Value

bool

IsFrozen

Gets a value indicating whether the settings have been frozen to prevent further changes.

public bool IsFrozen { get; }

Property Value

bool

LinqProvider

Gets or sets the LINQ provider.

public LinqProvider LinqProvider { get; set; }

Property Value

LinqProvider

LoadBalanced

Gets or sets whether load balanced mode is used.

public bool LoadBalanced { get; set; }

Property Value

bool

LocalThreshold

Gets or sets the local threshold.

public TimeSpan LocalThreshold { get; set; }

Property Value

TimeSpan

LoggingSettings

Gets or sets the logging settings

public LoggingSettings LoggingSettings { get; set; }

Property Value

LoggingSettings

MaxConnecting

Gets or sets the maximum concurrently connecting connections.

public int MaxConnecting { get; set; }

Property Value

int

MaxConnectionIdleTime

Gets or sets the max connection idle time.

public TimeSpan MaxConnectionIdleTime { get; set; }

Property Value

TimeSpan

MaxConnectionLifeTime

Gets or sets the max connection life time.

public TimeSpan MaxConnectionLifeTime { get; set; }

Property Value

TimeSpan

MaxConnectionPoolSize

Gets or sets the max connection pool size.

public int MaxConnectionPoolSize { get; set; }

Property Value

int

MinConnectionPoolSize

Gets or sets the min connection pool size.

public int MinConnectionPoolSize { get; set; }

Property Value

int

ReadConcern

Gets or sets the read concern.

public ReadConcern ReadConcern { get; set; }

Property Value

ReadConcern

ReadEncoding

Gets or sets the Read Encoding.

public UTF8Encoding ReadEncoding { get; set; }

Property Value

UTF8Encoding

ReadPreference

Gets or sets the read preferences.

public ReadPreference ReadPreference { get; set; }

Property Value

ReadPreference

ReplicaSetName

Gets or sets the name of the replica set.

public string ReplicaSetName { get; set; }

Property Value

string

RetryReads

Gets or sets whether to retry reads.

public bool RetryReads { get; set; }

Property Value

bool

RetryWrites

Gets or sets whether to retry writes.

public bool RetryWrites { get; set; }

Property Value

bool

The default value is true.

Scheme

Gets or sets the connection string scheme.

public ConnectionStringScheme Scheme { get; set; }

Property Value

ConnectionStringScheme

SdamLogFilename

Gets or set the name of the SDAM log file. Null turns logging off. stdout will log to console.

[Obsolete("Use LoggerFactory instead.")]
public string SdamLogFilename { get; set; }

Property Value

string

Server

Gets or sets the address of the server (see also Servers if using more than one address).

public MongoServerAddress Server { get; set; }

Property Value

MongoServerAddress

ServerApi

Gets or sets the server API.

public ServerApi ServerApi { get; set; }

Property Value

ServerApi

ServerSelectionTimeout

Gets or sets the server selection timeout.

public TimeSpan ServerSelectionTimeout { get; set; }

Property Value

TimeSpan

Servers

Gets or sets the list of server addresses (see also Server if using only one address).

public IEnumerable<MongoServerAddress> Servers { get; set; }

Property Value

IEnumerable<MongoServerAddress>

SocketTimeout

Gets or sets the socket timeout.

public TimeSpan SocketTimeout { get; set; }

Property Value

TimeSpan

SrvMaxHosts

Limits the number of SRV records used to populate the seedlist during initial discovery, as well as the number of additional hosts that may be added during SRV polling.

public int SrvMaxHosts { get; set; }

Property Value

int

SslSettings

Gets or sets the SSL settings.

public SslSettings SslSettings { get; set; }

Property Value

SslSettings

UseSsl

Gets or sets a value indicating whether to use SSL.

[Obsolete("Use UseTls instead.")]
public bool UseSsl { get; set; }

Property Value

bool

UseTls

Gets or sets a value indicating whether to use TLS.

public bool UseTls { get; set; }

Property Value

bool

VerifySslCertificate

Gets or sets a value indicating whether to verify an SSL certificate.

[Obsolete("Use AllowInsecureTls instead.")]
public bool VerifySslCertificate { get; set; }

Property Value

bool

WaitQueueSize

Gets or sets the wait queue size.

[Obsolete("This property will be removed in a later release.")]
public int WaitQueueSize { get; set; }

Property Value

int

WaitQueueTimeout

Gets or sets the wait queue timeout.

public TimeSpan WaitQueueTimeout { get; set; }

Property Value

TimeSpan

WriteConcern

Gets or sets the WriteConcern to use.

public WriteConcern WriteConcern { get; set; }

Property Value

WriteConcern

WriteEncoding

Gets or sets the Write Encoding.

public UTF8Encoding WriteEncoding { get; set; }

Property Value

UTF8Encoding

Methods

Clone()

Creates a clone of the settings.

public MongoClientSettings Clone()

Returns

MongoClientSettings

A clone of the settings.

Equals(MongoClientSettings)

Determines whether the specified MongoClientSettings is equal to this instance.

public bool Equals(MongoClientSettings obj)

Parameters

obj MongoClientSettings

The MongoClientSettings to compare with this instance.

Returns

bool

true if the specified MongoClientSettings is equal to this instance; otherwise, false.

Equals(object)

Determines whether the specified object is equal to this instance.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with this instance.

Returns

bool

true if the specified object is equal to this instance; otherwise, false.

Freeze()

Freezes the settings.

public MongoClientSettings Freeze()

Returns

MongoClientSettings

The frozen settings.

FromConnectionString(string)

Gets a MongoClientSettings object intialized with values from a connection string.

public static MongoClientSettings FromConnectionString(string connectionString)

Parameters

connectionString string

The connection string.

Returns

MongoClientSettings

A MongoClientSettings.

FromUrl(MongoUrl)

Gets a MongoClientSettings object intialized with values from a MongoURL.

public static MongoClientSettings FromUrl(MongoUrl url)

Parameters

url MongoUrl

The MongoURL.

Returns

MongoClientSettings

A MongoClientSettings.

FrozenCopy()

Returns a frozen copy of the settings.

public MongoClientSettings FrozenCopy()

Returns

MongoClientSettings

A frozen copy of the settings.

GetHashCode()

Gets the hash code.

public override int GetHashCode()

Returns

int

The hash code.

ToString()

Returns a string representation of the settings.

public override string ToString()

Returns

string

A string representation of the settings.

Operators

operator ==(MongoClientSettings, MongoClientSettings)

Determines whether two MongoClientSettings instances are equal.

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

Parameters

lhs MongoClientSettings

The LHS.

rhs MongoClientSettings

The RHS.

Returns

bool

true if the left hand side is equal to the right hand side; otherwise, false.

operator !=(MongoClientSettings, MongoClientSettings)

Determines whether two MongoClientSettings instances are not equal.

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

Parameters

lhs MongoClientSettings

The LHS.

rhs MongoClientSettings

The RHS.

Returns

bool

true if the left hand side is not equal to the right hand side; otherwise, false.