MongoServer MembersMongoDB C# Driver API Documentation
The MongoServer type exposes the following members.
Constructors

  NameDescription
Public methodMongoServer
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.
Back to 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 methodCopyDatabaseObsolete.
Copies a database.
Public methodStatic memberCreate Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodStatic memberCreate(String)Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodStatic memberCreate(Uri)Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodStatic memberCreate(MongoConnectionStringBuilder)Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodStatic memberCreate(MongoServerSettings)Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodStatic memberCreate(MongoUrl)Obsolete.
Creates a new instance or returns an existing instance of MongoServer. Only one instance is created for each combination of server settings.
Public methodCreateDatabaseSettingsObsolete.
Creates an instance of MongoDatabaseSettings for the named database with the rest of the settings inherited. You can override some of these settings before calling GetDatabase.
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 methodOnlineEquals
Determines whether the specified OnlineObject is equal to the current OnlineObject.
(Inherited from OnlineObject.)
Public methodFetchDBRef
Fetches the document referred to by the DBRef.
Public methodFetchDBRefAs(Type, MongoDBRef)
Fetches the document referred to by the DBRef.
Public methodFetchDBRefAs TDocument (MongoDBRef)
Fetches the document referred to by the DBRef, deserialized as a TDocument.
Protected methodOnlineFinalize
Allows an OnlineObject to attempt to free resources and perform other cleanup operations before the OnlineObject is reclaimed by garbage collection.
(Inherited from OnlineObject.)
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(MongoDatabaseSettings)Obsolete.
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 methodOnlineGetHashCode
Serves as a hash function for a particular type.
(Inherited from OnlineObject.)
Public methodGetLastError
Gets the last error (if any) that occurred on this connection. You MUST be within a RequestStart to call this method.
Public methodOnlineGetType
Gets the OnlineType of the current instance.
(Inherited from OnlineObject.)
Public methodIsDatabaseNameValid
Checks whether a given database name is valid on this server.
Protected methodOnlineMemberwiseClone
Creates a shallow copy of the current OnlineObject.
(Inherited from OnlineObject.)
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 methodRequestDone
Lets the server know that this thread is done with a series of related operations. Instead of calling this method it is better to put the return value of RequestStart in a using statement.
Public methodRequestStart(MongoDatabase)
Lets the server know that this thread is about to begin a series of related operations that must all occur on the same connection. The return value of this method implements IDisposable and can be placed in a using statement (in which case RequestDone will be called automatically when leaving the using statement).
Public methodRequestStart(MongoDatabase, MongoServerInstance)
Lets the server know that this thread is about to begin a series of related operations that must all occur on the same connection. The return value of this method implements IDisposable and can be placed in a using statement (in which case RequestDone will be called automatically when leaving the using statement).
Public methodRequestStart(MongoDatabase, ReadPreference)
Lets the server know that this thread is about to begin a series of related operations that must all occur on the same connection. The return value of this method implements IDisposable and can be placed in a using statement (in which case RequestDone will be called automatically when leaving the using statement).
Public methodRequestStart(MongoDatabase, Boolean)Obsolete.
Lets the server know that this thread is about to begin a series of related operations that must all occur on the same connection. The return value of this method implements IDisposable and can be placed in a using statement (in which case RequestDone will be called automatically when leaving the using statement).
Public methodShutdown
Shuts down the server.
Public methodOnlineToString
Returns a OnlineString that represents the current OnlineObject.
(Inherited from OnlineObject.)
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 methodVerifyState
Verifies the state of the server (in the case of a replica set all members are contacted one at a time).
Back to Top
Extension Methods

  NameDescription
Public Extension MethodToBson(Type)Overloaded.
Converts an object to a BSON document byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBson(Type, IBsonSerializationOptions)Overloaded.
Converts an object to a BSON document byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBson(Type, BsonBinaryWriterSettings)Overloaded.
Converts an object to a BSON document byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBson(Type, IBsonSerializationOptions, BsonBinaryWriterSettings)Overloaded.
Converts an object to a BSON document byte array.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBsonDocument(Type)Overloaded.
Converts an object to a BsonDocument.
(Defined by BsonExtensionMethods.)
Public Extension MethodToBsonDocument(Type, IBsonSerializationOptions)Overloaded.
Converts an object to a BsonDocument.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson(Type)Overloaded.
Converts an object to a JSON string.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson(Type, IBsonSerializationOptions)Overloaded.
Converts an object to a JSON string.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson(Type, JsonWriterSettings)Overloaded.
Converts an object to a JSON string.
(Defined by BsonExtensionMethods.)
Public Extension MethodToJson(Type, IBsonSerializationOptions, JsonWriterSettings)Overloaded.
Converts an object to a JSON string.
(Defined by BsonExtensionMethods.)
Back to Top
Properties

  NameDescription
Public propertyArbiters
Gets the arbiter instances.
Public propertyBuildInfo
Gets the build info of the server.
Public propertyConnectionAttempt
Gets the most recent connection attempt number.
Public propertyInstance
Gets the one and only instance for this server.
Public propertyInstances
Gets the instances for this server.
Public propertyItem String Obsolete.
Gets a MongoDatabase instance representing a database on this server.
Public propertyItem MongoDatabaseSettings Obsolete.
Gets a MongoDatabase instance representing a database on this server.
Public propertyItem String, 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
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 propertyRequestConnection
Gets the connection reserved by the current RequestStart scope (null if not in the scope of a RequestStart).
Public propertyRequestNestingLevel
Gets the RequestStart nesting level for the current thread.
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).
Back to Top
See Also