Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Using a shared MongoClient or MongoDatabase instance #43

@ducas

Description

@ducas

I'm using a MongoDB instance behind self-signed SSL, which means that to use this project I need to include sslVerifyCertificate=false on my connection string... that's bad. 😢

Do you think it would be a good idea to be able to initialise a MongoRepository by passing it a MongoClient. e.g.

var settings = new MongoClientSettings{ /*...*/ }
var client = new MongoClient(settings);
var db = client.GetServer().GetDatabase("mydb");
var repository = new MongoRepository(db, "mycollection");

Also it could be good to have a factory or context that provides the repositories -

var context = new MongoContext(db);
var repository = context.Repository<MyType>("mycollection");

This way you could pass an initialised context around and easily create repositories.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions