[CSHARP-99] ConnectionString should determine if it needs to check in the .config file for the Connection String Created: 16/Nov/10 Updated: 20/Mar/14 Resolved: 16/Nov/10 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.7 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Andre' Hazelwood | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
If a ConnectionString name is passed into the driver, the driver should look to see if it is a valid Connection string, and if not, attempt to get a connection string from the configuration file through ConfigurationManager. |
| Comments |
| Comment by Robert Stam [ 16/Nov/10 ] |
|
Wrote a little test with SqlConnection, and the following line throws an exception: var connection = new SqlConnection("MyConnectionString"); even though "MyConnectionString" is in the config file. The exception is of type ArgumentException and the error message reads: "Format of the initialization string does not conform to specification starting at index 0.". So it looks like it is not standard behavior to automatically read the config file. |
| Comment by Robert Stam [ 16/Nov/10 ] |
|
I was looking at the documentation for SqlConnection and it doesn't mention anything about automatically consulting ConfigurationManager if the connection string is invalid (does it even do that?). Are you sure this is something developers expect? I know I've never expected it. |
| Comment by Andre' Hazelwood [ 16/Nov/10 ] |
|
While I agree in part with you, I think that developers are so used to being able to assume passing in a ConnectionString name is a valid way to reference Connection strings, that implementing it would seem a natural way to make it easier for developers coming from other databases to interact with the MongoDB driver. Other implemented drivers, such as NoRM already allow this, so I would argue for including it as an option. |
| Comment by Robert Stam [ 16/Nov/10 ] |
|
The driver should never make any assumptions about where the connection string is coming from (not even to assume ConfigurationManager is the right choice). It should always be up to the client code to decide where it wants to fetch connection strings from. |