I have a class in c# that takes in 2 parameters: dependency on MongoDB database and a string variable denoting the name of the collection in the DB. How can I register this class in Program.cs?
My MongoRepository class:
namespace Play.Catalog.Service.Repositories
{
public class MongoRepository<T> : IRepository<T> where T: IEntity
{
private readonly IMongoCollection<T> dbCollection;
private readonly FilterDefinitionBuilder<T> filterBuilder = Builders<T>.Filter;
public MongoRepository(IMongoDatabase database, string collectionName)
{
dbCollection = database.GetCollection<T>(collectionName);
}
...
}
I am using .net6