Table of Contents

Class ConnectionString

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

Represents a connection string.

public sealed class ConnectionString
Inheritance
ConnectionString
Inherited Members

Constructors

ConnectionString(string)

Initializes a new instance of the ConnectionString class.

public ConnectionString(string connectionString)

Parameters

connectionString string

The connection string.

Properties

AllOptionNames

Gets all the option names.

public IEnumerable<string> AllOptionNames { get; }

Property Value

IEnumerable<string>

AllUnknownOptionNames

Gets all the unknown option names.

public IEnumerable<string> AllUnknownOptionNames { get; }

Property Value

IEnumerable<string>

ApplicationName

Gets the application name.

public string ApplicationName { get; }

Property Value

string

AuthMechanism

Gets the auth mechanism.

public string AuthMechanism { get; }

Property Value

string

AuthMechanismProperties

Gets the auth mechanism properties.

public IReadOnlyDictionary<string, string> AuthMechanismProperties { get; }

Property Value

IReadOnlyDictionary<string, string>

AuthSource

Gets the auth source.

public string AuthSource { get; }

Property Value

string

Compressors

Gets the requested compressors.

public IReadOnlyList<CompressorConfiguration> Compressors { get; }

Property Value

IReadOnlyList<CompressorConfiguration>

Connect

Gets the connection mode.

[Obsolete("Use DirectConnection instead.")]
public ClusterConnectionMode Connect { get; }

Property Value

ClusterConnectionMode

ConnectTimeout

Gets the connect timeout.

public TimeSpan? ConnectTimeout { get; }

Property Value

TimeSpan?

ConnectionModeSwitch

Gets the connection mode switch.

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

Property Value

ConnectionModeSwitch

DatabaseName

Gets the name of the database.

public string DatabaseName { get; }

Property Value

string

DirectConnection

Gets the directConnection.

public bool? DirectConnection { get; }

Property Value

bool?

FSync

Gets the fsync value of the write concern.

public bool? FSync { get; }

Property Value

bool?

HeartbeatInterval

Gets the heartbeat interval.

public TimeSpan? HeartbeatInterval { get; }

Property Value

TimeSpan?

HeartbeatTimeout

Gets the heartbeat timeout.

public TimeSpan? HeartbeatTimeout { get; }

Property Value

TimeSpan?

Hosts

Gets the hosts.

public IReadOnlyList<EndPoint> Hosts { get; }

Property Value

IReadOnlyList<EndPoint>

Ipv6

Gets whether to use IPv6.

public bool? Ipv6 { get; }

Property Value

bool?

IsResolved

Gets whether the connection string has been resolved. Always true when scheme is MongoDB.

public bool IsResolved { get; }

Property Value

bool

Journal

Gets the journal value of the write concern.

public bool? Journal { get; }

Property Value

bool?

LoadBalanced

Gets a value indicating whether load balanced mode is used.

public bool LoadBalanced { get; }

Property Value

bool

LocalThreshold

Gets the local threshold.

public TimeSpan? LocalThreshold { get; }

Property Value

TimeSpan?

MaxConnecting

Gets the maximum number of connections a pool may be establishing concurrently. Defaults to 2.

public int? MaxConnecting { get; }

Property Value

int?

MaxIdleTime

Gets the max idle time.

public TimeSpan? MaxIdleTime { get; }

Property Value

TimeSpan?

MaxLifeTime

Gets the max life time.

public TimeSpan? MaxLifeTime { get; }

Property Value

TimeSpan?

MaxPoolSize

Gets the max size of the connection pool.

public int? MaxPoolSize { get; }

Property Value

int?

MaxStaleness

Gets the max staleness.

public TimeSpan? MaxStaleness { get; }

Property Value

TimeSpan?

MinPoolSize

Gets the min size of the connection pool.

public int? MinPoolSize { get; }

Property Value

int?

Password

Gets the password.

public string Password { get; }

Property Value

string

ReadConcernLevel

Gets the read concern level.

public ReadConcernLevel? ReadConcernLevel { get; }

Property Value

ReadConcernLevel?

The read concern level.

ReadPreference

Gets the read preference.

public ReadPreferenceMode? ReadPreference { get; }

Property Value

ReadPreferenceMode?

ReadPreferenceTags

Gets the read preference tags.

public IReadOnlyList<TagSet> ReadPreferenceTags { get; }

Property Value

IReadOnlyList<TagSet>

ReplicaSet

Gets the replica set name.

public string ReplicaSet { get; }

Property Value

string

RetryReads

Gets a value indicating whether or not to retry reads.

public bool? RetryReads { get; }

Property Value

bool?

RetryWrites

Gets a value indicating whether or not to retry writes.

public bool? RetryWrites { get; }

Property Value

bool?

Scheme

Gets the connection string scheme.

public ConnectionStringScheme Scheme { get; }

Property Value

ConnectionStringScheme

ServerSelectionTimeout

Gets the server selection timeout.

public TimeSpan? ServerSelectionTimeout { get; }

Property Value

TimeSpan?

SocketTimeout

Gets the socket timeout.

public TimeSpan? SocketTimeout { get; }

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; }

Property Value

int?

Ssl

Gets whether to use SSL.

[Obsolete("Use Tls instead.")]
public bool? Ssl { get; }

Property Value

bool?

SslVerifyCertificate

Gets whether to verify SSL certificates.

[Obsolete("Use TlsInsecure instead.")]
public bool? SslVerifyCertificate { get; }

Property Value

bool?

Tls

Gets whether to use TLS.

public bool? Tls { get; }

Property Value

bool?

TlsDisableCertificateRevocationCheck

Get whether or not certificate revocation checking is disabled during the TLS handshake.

public bool? TlsDisableCertificateRevocationCheck { get; }

Property Value

bool?

TlsInsecure

Gets whether to relax TLS constraints as much as possible.

public bool? TlsInsecure { get; }

Property Value

bool?

Username

Gets the username.

public string Username { get; }

Property Value

string

UuidRepresentation

Gets the UUID representation.

public GuidRepresentation? UuidRepresentation { get; }

Property Value

GuidRepresentation?

W

Gets the w value of the write concern.

public WriteConcern.WValue W { get; }

Property Value

WriteConcern.WValue

WTimeout

Gets the wtimeout value of the write concern.

public TimeSpan? WTimeout { get; }

Property Value

TimeSpan?

WaitQueueMultiple

Gets the wait queue multiple.

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

Property Value

double?

WaitQueueSize

Gets the wait queue size.

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

Property Value

int?

WaitQueueTimeout

Gets the wait queue timeout.

public TimeSpan? WaitQueueTimeout { get; }

Property Value

TimeSpan?

Methods

GetOption(string)

Gets the option.

public string GetOption(string name)

Parameters

name string

The name.

Returns

string

The option with the specified name.

Resolve(bool, CancellationToken)

Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.

public ConnectionString Resolve(bool resolveHosts, CancellationToken cancellationToken = default)

Parameters

resolveHosts bool

Whether to resolve hosts.

cancellationToken CancellationToken

The cancellation token.

Returns

ConnectionString

A resolved ConnectionString.

Resolve(CancellationToken)

Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.

public ConnectionString Resolve(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

ConnectionString

A resolved ConnectionString.

ResolveAsync(bool, CancellationToken)

Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.

public Task<ConnectionString> ResolveAsync(bool resolveHosts, CancellationToken cancellationToken = default)

Parameters

resolveHosts bool

Whether to resolve hosts.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ConnectionString>

A resolved ConnectionString.

ResolveAsync(CancellationToken)

Resolves a connection string. If the connection string indicates more information is available in the DNS system, it will acquire that information as well.

public Task<ConnectionString> ResolveAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ConnectionString>

A resolved ConnectionString.

ToString()

public override string ToString()

Returns

string