如何從應用程式連線 MongoDb 資料庫

定義引數

private static IMongoClient _client;
private static IMongoDatabase _database;
private static IMongoCollection< -collection class name- > _collection;

為引數指定值

_client = new MongoClient("mongodb://localhost:27017");
_database = _client.GetDatabase("database name here");
_collection = _database.GetCollection< -collection class name- >("collection name here");