bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
136 stars 47 forks source link

Multiple Company DI Connection Dictionary #69

Closed matheusfellipe closed 4 months ago

matheusfellipe commented 5 months ago

I'm getting DI error using the connection dictionary in service collection extensions method, like

 public static IServiceCollection AddB1SLayer(this IServiceCollection services, IConfiguration configuration)
 {

     services.AddSingleton(serviceLayer => 
     new Dictionary<string,SLConnection>()
     {
         { "foo", new SLConnection(configuration["Url"], "companyDb", configuration["UserName"],  configuration["PassWord"]) },
          { "boo", new SLConnection(configuration["Url"],  "companyDb", configuration["UserName"],  configuration["PassWord"]) }

     });

     return services;
 }

}

EricWu91 commented 5 months ago

Hi! What's the error? Can you provide us the Stack Traces? Also, where is the exception thrown?

matheusfellipe commented 4 months ago

I was injecting SLConnection rather than the dictionary