From 1826668cea4709449d1589559e00e33ad55a4592 Mon Sep 17 00:00:00 2001 From: Alexandre SPIESER Date: Mon, 15 Apr 2019 00:47:06 +0100 Subject: [PATCH] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index d0daa59..76da538 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,18 @@ Here is an example of repository usage, where the TestRepository is implementing } } ``` +If all your documents have the same type of key, you can use the more specific `BaseMongoRepository` where `TKey` is the type of the `Id` of your documents. +``` + public class TestTKeyRepository : BaseMongoRepository, ITestRepository where TKey : IEquatable + { + const string connectionString = "mongodb://localhost:27017/MongoDbTests"; + private static readonly ITestRepository _instance = new TestTKeyRepository(connectionString); + /// + private TestTKeyRepository(string connectionString) : base(connectionString) + { + } + } +``` ## Instantiation @@ -47,6 +59,7 @@ The repository can be instantiated like so: ```csharp ITestRepository testRepository = new TestRepository(connectionString, "MongoDbTests"); +ITestRepository testTKeyRepository = new TestTKeyRepository(connectionString); ``` If you prefer to reuse the same MongoDb database across your application, you can use the `MongoDatabase` from the MongoDb driver implementing the `IMongoDatabase` interface: