public void GetClientWithNoTelemetry() { var factory = new MongoClientFactory(); var result = factory.GetClient("mongodb://localhost"); result.Settings.Server.Should().BeEquivalentTo( new MongoServerAddress("localhost", 27017)); }
public async Task <IActionResult> Get() { const string connectionString = "mongodb://localhost:27017"; var client = _clientFactory.GetClient(connectionString); var db = client.GetDatabase("TestDb"); var collection = db.GetCollection <BsonDocument>("CollectionA"); for (var i = 0; i < 5; i++) { await collection.FindAsync(new JsonFilterDefinition <BsonDocument>("{'A':123}")); } return(Ok()); }
static void Main() { var connectionString = "mongodb://localhost:27017"; var logger = new Logger(); var mongoClientFactory = new MongoClientFactory(logger, new MongoClientSettingsFactorySettings(), logger); var client = mongoClientFactory.GetClient(connectionString); var db = client.GetDatabase("TestDb"); var collection = db.GetCollection <BsonDocument>("CollectionA"); for (int i = 0; i < 5; i++) { collection.FindAsync(new JsonFilterDefinition <BsonDocument>("{'A':123}")).GetAwaiter().GetResult(); } Console.ReadKey(); }