[CSHARP-970] MongoServer.GetDatabase does not return the same instance Created: 11/May/14 Updated: 02/Apr/15 Resolved: 12/May/14 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Documentation |
| Affects Version/s: | 1.9 |
| Fix Version/s: | 1.9.1 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Ben Foster | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
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() before = () => ; act = () => db2 = server.GetDatabase(dbName); context["when the database name is the same"] = () => ; Have I misunderstood the documentation as looking through the source code it appears that GetDatabase always returns a new MongoDatabase instance. |
| Comments |
| Comment by Robert Stam [ 12/May/14 ] |
|
Corrected XML doc comments. |
| Comment by Githook User [ 12/May/14 ] |
|
Author: {u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |
| Comment by Githook User [ 12/May/14 ] |
|
Author: {u'name': u'rstam', u'email': u'robert@10gen.com'}Message: |
| Comment by Robert Stam [ 11/May/14 ] |
|
If you can hold on to the MongoDatabase instance and use it repeatedly you will create slightly less work for the garbage collector. But MongoDatabase is a light weight class that would be cheap to create and garbage collect, so either way is fine. |
| Comment by Ben Foster [ 11/May/14 ] |
|
Hi Robert, Is there any reason why we should keep hold of the MongoDatabase instance Thanks |
| Comment by Robert Stam [ 11/May/14 ] |
|
Sorry. The documentation is wrong. GetDatabase will return a new instance of MongoDatabase each time it is called. We will get the documentation corrected. Thanks for reporting this. |