Skip to content

Add Dependency Injection overload that takes an action with an IServiceProvider parameter #1316

Closed
@bgrainger

Description

@bgrainger

Add the following overload to MySqlConnector.DependencyInjection:

public static IServiceCollection AddMySqlDataSource(
	this IServiceCollection serviceCollection,
	string? connectionString,
	Action<IServiceProvider, MySqlDataSourceBuilder> dataSourceBuilderAction, // THIS IS THE CHANGE
	ServiceLifetime connectionLifetime = ServiceLifetime.Transient,
	ServiceLifetime dataSourceLifetime = ServiceLifetime.Singleton);

This would allow users to configure the MySqlDataSourceBuilder from services, e.g., getting the connection string or a periodic password provider from services. (Without having to recreate MySqlConnector.DependencyInjection themselves.)

Should align with npgsql/npgsql#4822 on final API.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions