[CSHARP-2141] Create Causal Consistency code samples for MongoDB 3.6 page Created: 05/Jan/18  Updated: 28/Oct/23  Resolved: 29/Nov/18

Status: Closed
Project: C# Driver
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-434 Provide code samples for MongoDB 3.6 ... Closed

 Description   

Please provide the equivalent C# code for the following Java example:

Causal Consistency

// 2. Tunable consistency controls
String connectionString = "mongodb://localhost/?readPreference=secondaryPreferred";
 
MongoClient client = new MongoClient(new MongoClientURI(connectionString);
 
MongoDatabase database = client.getDatabase("myDatabase");
MongoCollection<Document> collection = database.getCollection("myCollection");
 
// Start client session, which is causally consistent by default
try (ClientSession session = client.startSession(ClientSessionOptions.builder().build())) {
  //Run causally related operations within the session
  collection.insertOne(session, ...);
  collection.updateOne(session, ...);
 
  try (MongoCursor<Document> cursor = collection.find(session).filter(...).iterator()) {
    while (cursor.hasNext()) {
      Document cur = cursor.next();
    }
  }
}



 Comments   
Comment by Githook User [ 29/Nov/18 ]

Author:

{'name': 'Dmitry Lukyanov', 'email': 'dmitry_lukyanov@epam.com', 'username': 'dmitry-lukyanov'}

Message: CSHARP-2141: Add documentation sample for causal consistency.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/9ba82a66967a1c10e705d5ce80eae7121f7b0f74

Comment by Dmitry Lukyanov (Inactive) [ 29/Nov/18 ]

Used example delimiters:

// Start Tunable Consistency Controls Example
// End Tunable Consistency Controls Example

Generated at Wed Feb 07 21:41:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.