shopping-assistant-api/ShoppingAssistantApi.Persistance/Database/MongoDbContext.cs
2023-10-16 03:23:07 +00:00

21 lines
584 B
C#

using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
namespace ShoppingAssistantApi.Persistance.Database;
public class MongoDbContext
{
private readonly MongoClient _client;
private readonly IMongoDatabase _db;
public MongoDbContext(IConfiguration configuration)
{
this._client = new MongoClient(configuration.GetConnectionString("MongoDb"));
this._db = this._client.GetDatabase(configuration.GetConnectionString("MongoDatabaseName"));
}
public IMongoDatabase Db => this._db;
public MongoClient Client => this._client;
}