ServiceCollectionExtensions
Extension methods for adding and configuring the Azure Cosmos DB services.
Namespace: Microsoft.Extensions.DependencyInjection
Kind: class
Extension methods for adding and configuring the Azure Cosmos DB services.
public static class ServiceCollectionExtensionsExample
Members
Methods
ServiceCollectionExtensions.AddCosmosRepository(IServiceCollection, Action<RepositoryOptions>?, Action<CosmosClientOptions>?)
Adds the services required to consume any number of IRepository
instances to interact with Cosmos DB.
public static IServiceCollection AddCosmosRepository(this IServiceCollection services, Action<RepositoryOptions>? setupAction = null, Action<CosmosClientOptions>? additionalSetupAction = null)Parameters
| Name | Type | Description |
|---|---|---|
services | IServiceCollection | The service collection to add services to. |
setupAction | RepositoryOptions} | An action to configure the repository options |
additionalSetupAction | CosmosClientOptions} | An action to configure the CosmosClientOptions |
Returns — IServiceCollection: The same service collection that was provided, with the required cosmos services.
ServiceCollectionExtensions.AddInMemoryCosmosRepository(IServiceCollection)
Adds the services required to run the in memory implementation of the cosmos repository.
public static IServiceCollection AddInMemoryCosmosRepository(this IServiceCollection services)Parameters
| Name | Type | Description |
|---|---|---|
services | IServiceCollection | The service collection to add services to. |
Returns — IServiceCollection
ServiceCollectionExtensions.RemoveCosmosRepositories(IServiceCollection)
Remove all of IRepository from the container.
public static IServiceCollection RemoveCosmosRepositories(this IServiceCollection services)Parameters
| Name | Type | Description |
|---|---|---|
services | IServiceCollection | The service collection to add services to. |
Returns — IServiceCollection