I am trying to use the generic Lazy class to instantiate a costly class with .net core dependency injection extension. I have registered the IRepo type, but I\'m not sure wh
Here's another approach which supports generic registration of Lazy so that any type can be resolved lazily.
services.AddTransient(typeof(Lazy<>), typeof(Lazier<>));
internal class Lazier : Lazy where T : class
{
public Lazier(IServiceProvider provider)
: base(() => provider.GetRequiredService())
{
}
}