Mongo DB - List Databases -Sample c# console project


  using MongoDB.Driver;

using System;

namespace MongoDBConsoleAppListDatabases
{
    class Program
    {
        static void Main(string[] args)
        {
            var dbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var dbList = dbClient.ListDatabases().ToList();
            Console.WriteLine("The list of databases are:");
            foreach (var item in dbList)
            {
                Console.WriteLine(item);

                Console.WriteLine(" ----- ----- ----- ");
            }

            Console.ReadKey();

        }
    }
}

//**** Github public :
https://github.com/doktoralban/MongoDBConsoleAppListDatabases

Yorumlar