Update IoC and the "GET" function in the repository (lock issue)

This commit is contained in:
Sébastien André
2019-11-10 20:03:03 +01:00
parent f3f9b91a15
commit 2e6ec6ec85
9 changed files with 40 additions and 34 deletions

View File

@@ -1,12 +1,15 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace skydiveLogs_api.Ioc
{
public class IocService
{
public IocService(IServiceCollection services)
public IocService(IServiceCollection services,
IConfiguration configuration)
{
_services = services;
_configuration = configuration;
}
public void Configure()
@@ -28,9 +31,12 @@ namespace skydiveLogs_api.Ioc
_services.AddScoped<Data.Interface.IJumpTypeRepository, Data.JumpTypeRepository>();
_services.AddScoped<Data.Interface.IGearRepository, Data.GearRepository>();
_services.AddScoped<Data.Interface.IDataProvider, Data.LiteDbProvider>();
string connectionString = _configuration.GetConnectionString("DefaultConnection");
_services.AddScoped<Data.Interface.IDataProvider>(c => new Data.LiteDbProvider(connectionString));
}
private readonly IServiceCollection _services;
private readonly IConfiguration _configuration;
}
}