Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions