Update README.md

This commit is contained in:
Alexandre SPIESER
2017-11-01 08:27:59 +00:00
committed by GitHub
parent 657beeac99
commit e91c89f054
+8
View File
@@ -46,6 +46,14 @@ The repository can be instantiated like so:
ITestRepository testRepository = new TestRepository(connectionString, "MongoDbTests"); ITestRepository testRepository = new TestRepository(connectionString, "MongoDbTests");
``` ```
If you prefer to reuse the same MongoDb database across you application, you can use the `MongoDatabase` from the MongoDb driver implementing the `IMongoDatabase` interface:
```csharp
var client = new MongoClient(connectionString);
var mongoDbDatabase = Client.GetDatabase(databaseName);
ITestRepository testRepository = new TestRepository(mongoDbDatabase);
```
## Adding documents ## Adding documents
To add a document, its class must inherit from the `Document` class, implement the `IDocument` or `IDocument<TKey>` interface: To add a document, its class must inherit from the `Document` class, implement the `IDocument` or `IDocument<TKey>` interface: