-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.6.1
-
Component/s: None
-
None
-
Major Change
This JIRA was edited to remove mention of the FireAndForget keyword. See also CSHARP-627.
In the past the default WriteConcern for all drivers has been to not acknowledge writes. In the future this will no longer be the default WriteConcern, and the default behavior will be for drivers to send a simple
{ getlasterror : 1 }command after every insert/update operation. Additional arguments to the getLastError command can be configured using WriteConcern properties.
Because existing code may depend on the previous default, we are introducing a new root object (called MongoClient). When you use the new root object, acknowledging writes will be the new default.
Of course, if your connection string includes any WriteConcern related settings they will override the default (regardless of what the default is).
Currently, C# applications begin using MongoDB like this:
var connectionString = "mongodb://hostname"; var server = MongoServer.Create(connectionString);
In the future, the correct way to begin using MongoDB is:
var connectionString = "mongodb://hostname"; var client = new MongoClient(connectionString); var server = client.GetServer();
If you don't plan to call any methods from MongoServer (usually you won't) you can navigate directly from the client object to a database object:
var database = client.GetDatabase("test");
Except for replacing the call to MongoServer.Create with instantiating a MongoClient and calling GetServer, from then on your application will continue to use the existing API unchanged (although see the related JIRA where we are replacing SafeMode with WriteConcern).
The existing MongoServer.Create methods will continue to exist for a few releases, but they are being marked Obsolete to generate warnings to remind you to use MongoClient instead. Therefore this change is slightly backward breaking in the short term (because warnings are introduced) and backward breaking in the long term since the MongoServer.Create methods will eventually be removed.
- related to
-
CSHARP-627 Remove FireAndForget and use magic values for "w" instead
- Closed
-
CSHARP-615 Replace SafeMode with WriteConcern
- Closed