Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for keyed services in DI #1391

Closed
bgrainger opened this issue Nov 11, 2023 · 2 comments
Closed

Add support for keyed services in DI #1391

bgrainger opened this issue Nov 11, 2023 · 2 comments

Comments

@bgrainger
Copy link
Member

.NET 8.0 is adding support for keyed services; we should add AddMySqlDataSource overloads which accept a key. This is ideal for registering multiple data sources in the same DI container, and later selecting which one you want via e.g. [FromKeyedServices].

See related Npgsql issue: npgsql/npgsql#5134.

@roji
Copy link

roji commented Nov 16, 2023

@bgrainger you can check out the Npgsql implementation by @NinoFloris; we ended up just adding an optional parameter to do it, rather than add method overloads with the "Keyed" prefix (you can see the discussion there if interested).

@bgrainger
Copy link
Member Author

Thanks. Not sure yet if I follow (or agree with) the rationale for avoiding Keyed in the method names, but I'll do some more reading on it. (My initial reaction is that AddKeyedMySqlDataSource would be better for clarify and disambiguating overloads.)

bgrainger added a commit that referenced this issue Nov 16, 2023
Add tests for MySqlConnector.DependencyInjection project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants