How to register many for open generic in Autofac

后端 未结 2 2000
挽巷
挽巷 2020-12-28 14:55

I\'m new to Autofac (not to DI). Here is the situation:

I have these interfaces:

public interface IQuery

        
2条回答
  •  醉梦人生
    2020-12-28 15:36

    If you have a single concrete generic type, and don't want the scanning overhead and improve the startup performance, you can register as below:

    builder.RegisterGeneric(typeof(ConcreteGenericType<>)).As(typeof(IServiceType<>);
    

提交回复
热议问题