Interface IMongoClientFactory<TContext>
Define the behavior expected from the factory to create a mongo client and retrieve the database (part of the description).
public interface IMongoClientFactory<TContext> where TContext : DbContext
Type Parameters
TContextThe type of the database context.
Methods
CreateClient()
Gets the MongoDB client of the context.
IMongoClient CreateClient()
Returns
- IMongoClient
The client.
GetCollection<TEntity>()
Gets the collection the entity type is mapped to in the DbContext.
IMongoCollection<TEntity> GetCollection<TEntity>()
Returns
- IMongoCollection<TEntity>
The collection.
Type Parameters
TEntityThe document type of the collection.
GetCollection<TEntity>(string)
Gets a collection of the database by name.
IMongoCollection<TEntity> GetCollection<TEntity>(string collectionName)
Parameters
collectionNamestringThe name of the collection.
Returns
- IMongoCollection<TEntity>
The collection.
Type Parameters
TEntityThe document type of the collection.