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

AddMartenStore<T> extension with Func<IServiceProvider, StoreOptions> argument doesn't work as expected #2659

Closed
CommitedSajmon opened this issue Jul 25, 2023 · 0 comments
Milestone

Comments

@CommitedSajmon
Copy link

CommitedSajmon commented Jul 25, 2023

Below extension method is not working as expected.

public static MartenStoreExpression<T> AddMartenStore<T>(this IServiceCollection services, Func<IServiceProvider, StoreOptions> configure) where T : class, IDocumentStore

I am not able to get registered store using AllDocumentStores

public static IReadOnlyList<IDocumentStore> AllDocumentStores(this IServiceProvider services);

However, AllDocumentStores works fine if I register marten store using another extension method, it's the one that uses Action<StoreOptions> configure instead of Func<IServiceProvider, StoreOptions> configure.

MartenStoreExpression<T> AddMartenStore<T>(this IServiceCollection services, Action<StoreOptions> configure)

Seems like services.AddSingleton<IDocumentStoreSource, DocumentStoreSource<T>>(); call is missing in AddMartenStore<T>(this IServiceCollection services, Func<IServiceProvider, StoreOptions> configure).

I would suggest to move services.AddSingleton<IDocumentStoreSource, DocumentStoreSource<T>>(); registration from MartenStoreExpression<T> AddMartenStore<T>(this IServiceCollection services, Action<StoreOptions> configure) to AddMartenStore<T>(this IServiceCollection services, Func<IServiceProvider, StoreOptions> configure) or make the latter extension internal if it's not supposed to be used.

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

No branches or pull requests

3 participants