Search documentationEsc

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 ServiceCollectionExtensions

Example

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

NameTypeDescription
servicesIServiceCollectionThe service collection to add services to.
setupActionRepositoryOptions}An action to configure the repository options
additionalSetupActionCosmosClientOptions}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

NameTypeDescription
servicesIServiceCollectionThe 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

NameTypeDescription
servicesIServiceCollectionThe service collection to add services to.

Returns — IServiceCollection