December 2019
Intermediate to advanced
528 pages
11h 19m
English
To create a MongoDbRepository class, we need to go through the following steps:

public class MongoDBRepository
{
public readonly IMongoDatabase Database;
public MongoDBRepository(IOptions<Settings> settings)
{
try
{
var mclient = new MongoClient(settings.Value.ConnectionString);
Database = mclient.GetDatabase(settings.Value.Database);
}
catch (Exception ex)
{
throw new Exception("There was a problem connecting to the MongoDB database", ex); ...