In the code below, serviceProvider.GetService<DocumentDbConnection>() resolves to null :
public void ConfigureService(IServiceCollection services) { var serviceProvider = services.BuildServiceProvider(); services.AddSingleton<DocumentDbConnection>( x => new DocumentDbConnection(uri, authKey));
Why is this happening? GetService type registered before GetService is called so that it does not allow singleton?
c # dependency-injection asp.net-core asp.net-core-mvc
davenewza
source share