Click or drag to resize

MongoServer Class

Represents a MongoDB server (either a single instance or a replica set) and the settings used to access it. This class is thread-safe.
Inheritance Hierarchy
SystemObject
  MongoDB.DriverMongoServer

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.7.3+Branch.v2.7.x.Sha.2f1f2be13a23b8520cb9c2ee8439c022f9a03efe
Syntax
public class MongoServer

The MongoServer type exposes the following members.

Constructors
  NameDescription
Public methodMongoServer Obsolete.
Creates a new instance of MongoServer. Normally you will use one of the Create methods instead of the constructor to create instances of this class.
Top
Properties
  NameDescription
Public propertyArbiters
Gets the arbiter instances.
Public propertyBuildInfo
Gets the build info of the server.
Public propertyInstance
Gets the one and only instance for this server.
Public propertyInstances
Gets the instances for this server.
Public propertyItemString Obsolete.
Gets a MongoDatabase instance representing a database on this server.
Public propertyItemString, WriteConcern Obsolete.
Gets a MongoDatabase instance representing a database on this server.
Public propertyStatic memberMaxServerCount
Gets or sets the maximum number of instances of MongoServer that will be allowed to be created.
Public propertyPassives Obsolete.
Gets the passive instances.
Public propertyPrimary
Gets the primary instance (null if there is no primary).
Public propertyReplicaSetName
Gets the name of the replica set (null if not connected to a replica set).
Public propertySecondaries
Gets the secondary instances.
Public propertySequentialId
Gets the unique sequential Id for this server.
Public propertyStatic memberServerCount
Gets the number of instances of MongoServer that have been created.
Public propertySettings
Gets the settings for this server.
Public propertyState
Gets the current state of this server (as of the last operation, not updated until another operation is performed).
Top
Methods
  NameDescription
Public methodConnect
Connects to the server. Normally there is no need to call this method as the driver will connect to the server automatically when needed.
Public methodConnect(TimeSpan)
Connects to the server. Normally there is no need to call this method as the driver will connect to the server automatically when needed.
Public methodDatabaseExists
Tests whether a database exists.
Public methodDisconnect
Disconnects from the server. Normally there is no need to call this method so you should be sure to have a good reason to call it.
Public methodDropDatabase
Drops a database.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodFetchDBRef
Fetches the document referred to by the DBRef.
Public methodFetchDBRefAs(Type, MongoDBRef)
Fetches the document referred to by the DBRef.
Public methodFetchDBRefAsTDocument(MongoDBRef)
Fetches the document referred to by the DBRef, deserialized as a TDocument.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodStatic memberGetAllServers
Gets an array containing a snapshot of the set of all servers that have been created so far.
Public methodGetDatabase(String)
Gets a MongoDatabase instance representing a database on this server.
Public methodGetDatabase(String, MongoDatabaseSettings)
Gets a MongoDatabase instance representing a database on this server.
Public methodGetDatabase(String, WriteConcern)
Gets a MongoDatabase instance representing a database on this server.
Public methodGetDatabaseNames
Gets the names of the databases on this server.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetServerInstance
Gets the server instance.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsDatabaseNameValid
Checks whether a given database name is valid on this server.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodPing
Checks whether the server is alive (throws an exception if not). If server is a replica set, pings all members one at a time.
Public methodReconnect
Reconnects to the server. Normally there is no need to call this method. All connections are closed and new connections will be opened as needed. Calling this method frequently will result in connection thrashing.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUnregisterAllServers
Unregisters all servers from the dictionary used by Create to remember which servers have already been created.
Public methodStatic memberUnregisterServer
Unregisters a server from the dictionary used by Create to remember which servers have already been created.
Public methodWithReadConcern
Returns a new MongoServer instance with a different read concern setting.
Public methodWithReadPreference
Returns a new MongoServer instance with a different read preference setting.
Public methodWithWriteConcern
Returns a new MongoServer instance with a different write concern setting.
Top
Extension Methods
  NameDescription
Public Extension MethodToBson
Serializes an object to a BSON byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBsonDocument
Serializes an object to a BsonDocument.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson
Serializes an object to a JSON string.
(Defined by BsonExtensionMethods.)
Top
See Also