Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-970

MongoServer.GetDatabase does not return the same instance

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9.1
    • Affects Version/s: 1.9
    • Component/s: Documentation
    • None

      According to the docs, MongoServer.GetDatabase should return the same instance when the same database settings (e.g. database name) are used. However, the following test fails:

      void describe_get_database()
      {
      MongoServer server = null;
      MongoDatabase db = null;
      MongoDatabase db2 = null;
      string dbName = null;

      before = () =>

      { var client = new MongoClient("mongodb://localhost"); server = client.GetServer(); dbName = "test"; db = server.GetDatabase(dbName); }

      ;

      act = () => db2 = server.GetDatabase(dbName);

      context["when the database name is the same"] = () =>

      { it["should return the same database instance"] = () => db2.should_be_same(db); }

      ;
      }

      Have I misunderstood the documentation as looking through the source code it appears that GetDatabase always returns a new MongoDatabase instance.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            benfosterdev Ben Foster
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: