shopping-assistant-api/ShoppingAssistantApi.Persistance/Database/MongoDbContext.cs
2023-09-22 23:02:20 +03:00

19 lines
536 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;
}