How do I correctly use Unity to pass a ConnectionString to my repository classes?

后端 未结 4 1114
抹茶落季
抹茶落季 2020-12-08 07:49

I\'ve literally just started using the Unity Application Blocks Dependency Injection library from Microsoft, and I\'ve come unstuck.

This is my IoC class that\'ll ha

4条回答
  •  星月不相逢
    2020-12-08 08:39

    You can configure the unity container for this:

    IUnityContainer container = new UnityContainer()
      .RegisterType(
        new InjectionConstructor("connectionstring goes here"));
    

    in XLM that would probably be something like this:

    
           
       
         
           
                    
       
      
    
    

    or wrap the connectionstring as mcaaltuntas points out.

提交回复
热议问题