Click or drag to resize
MongoDatabase Class
Represents a MongoDB database and the settings used to access it. This class is thread-safe.
Inheritance Hierarchy
SystemObject
  MongoDB.DriverMongoDatabase

Namespace: MongoDB.Driver
Assembly: MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.3.0
Syntax
public class MongoDatabase

The MongoDatabase type exposes the following members.

Constructors
  NameDescription
Public methodMongoDatabase
Creates a new instance of MongoDatabase. Normally you would call one of the indexers or GetDatabase methods of MongoServer instead.
Top
Properties
  NameDescription
Public propertyCommandCollection Obsolete.
Gets the command collection for this database.
Public propertyGridFS
Gets the default GridFS instance for this database. The default GridFS instance uses default GridFS settings. See also GetGridFS if you need to use GridFS with custom settings.
Public propertyItemString Obsolete.
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public propertyItemString, WriteConcern Obsolete.
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public propertyName
Gets the name of this database.
Public propertyServer
Gets the server that contains this database.
Public propertySettings
Gets the settings being used to access this database.
Top
Methods
  NameDescription
Public methodAddUser Obsolete.
Adds a user to this database.
Public methodCollectionExists
Tests whether a collection exists on this database.
Public methodCreateCollection(String)
Creates a collection. MongoDB creates collections automatically when they are first used, so this command is mainly here for frameworks.
Public methodCreateCollection(String, IMongoCollectionOptions)
Creates a collection. MongoDB creates collections automatically when they are first used, so you only need to call this method if you want to provide non-default options.
Public methodDrop
Drops a database.
Public methodDropCollection
Drops a collection.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodEval(EvalArgs)
Evaluates JavaScript code at the server.
Public methodEval(BsonJavaScript, Object) Obsolete.
Evaluates JavaScript code at the server.
Public methodEval(EvalFlags, BsonJavaScript, Object) Obsolete.
Evaluates JavaScript code at the server.
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 methodFindAllUsers Obsolete.
Finds all users of this database.
Public methodFindUser Obsolete.
Finds a user of this database.
Public methodGetCollection(String)
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public methodGetCollection(String, MongoCollectionSettings)
Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.
Public methodGetCollection(String, WriteConcern)
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public methodGetCollection(Type, String)
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public methodGetCollection(Type, String, MongoCollectionSettings)
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public methodGetCollection(Type, String, WriteConcern)
Gets a MongoCollection instance representing a collection on this database with a default document type of BsonDocument.
Public methodGetCollectionTDefaultDocument(String)
Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.
Public methodGetCollectionTDefaultDocument(String, MongoCollectionSettings)
Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.
Public methodGetCollectionTDefaultDocument(String, WriteConcern)
Gets a MongoCollection instance representing a collection on this database with a default document type of TDefaultDocument.
Public methodGetCollectionNames
Gets a list of the names of all the collections in this database.
Public methodGetCurrentOp
Gets the current operation.
Public methodGetGridFS
Gets an instance of MongoGridFS for this database using custom GridFS settings.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetProfilingInfo
Gets one or more documents from the system.profile collection.
Public methodGetProfilingLevel
Gets the current profiling level.
Public methodGetSisterDatabase
Gets a sister database on the same server.
Public methodGetStats
Gets the current database stats.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsCollectionNameValid
Checks whether a given collection name is valid in this database.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemoveUser(String) Obsolete.
Removes a user from this database.
Public methodRemoveUser(MongoUser) Obsolete.
Removes a user from this database.
Public methodRenameCollection(String, String)
Renames a collection on this database.
Public methodRenameCollection(String, String, Boolean)
Renames a collection on this database.
Public methodRunCommand(String)
Runs a command on this database.
Public methodRunCommand(IMongoCommand)
Runs a command on this database.
Public methodRunCommandAs(Type, IMongoCommand)
Runs a command on this database and returns the result as a TCommandResult.
Public methodRunCommandAs(Type, String)
Runs a command on this database and returns the result as a TCommandResult.
Public methodRunCommandAsTCommandResult(String)
Runs a command on this database and returns the result as a TCommandResult.
Public methodRunCommandAsTCommandResult(IMongoCommand)
Runs a command on this database and returns the result as a TCommandResult.
Public methodRunCommandAsTCommandResult(IMongoCommand, ReadPreference)
Runs a command on this database and returns the result as a TCommandResult.
Public methodSetProfilingLevel(ProfilingLevel)
Sets the level of profile information to write.
Public methodSetProfilingLevel(ProfilingLevel, TimeSpan)
Sets the level of profile information to write.
Public methodToString
Gets a canonical string representation for this database.
(Overrides ObjectToString.)
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