File tree Expand file tree Collapse file tree 3 files changed +5
-12
lines changed
Expand file tree Collapse file tree 3 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ internal static class DatabaseModule
1212
1313 internal static IServiceCollection AddDatabase ( this IServiceCollection services , IConfiguration configuration )
1414 {
15- services . Configure < DatabaseOptions > ( options => configuration . GetSection ( DatabaseConfigurationSection ) . Bind ( options ) ) ;
15+ services . Configure < DatabaseOptions > ( _ => configuration . GetSection ( DatabaseConfigurationSection ) ) ;
1616 services . AddDbContext < OffersPersistence > ( ( serviceProvider , options ) =>
1717 {
1818 var databaseOptions = serviceProvider . GetRequiredService < IOptions < DatabaseOptions > > ( ) ;
@@ -28,4 +28,4 @@ internal static IApplicationBuilder UseDatabase(this IApplicationBuilder applica
2828
2929 return applicationBuilder ;
3030 }
31- }
31+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ internal static class DatabaseModule
1212
1313 internal static IServiceCollection AddDatabase ( this IServiceCollection services , IConfiguration configuration )
1414 {
15- services . Configure < DatabaseOptions > ( options => configuration . GetSection ( DatabaseConfigurationSection ) . Bind ( options ) ) ;
15+ services . Configure < DatabaseOptions > ( _ => configuration . GetSection ( DatabaseConfigurationSection ) ) ;
1616 services . AddDbContext < PassesPersistence > ( ( serviceProvider , options ) =>
1717 {
1818 var databaseOptions = serviceProvider . GetRequiredService < IOptions < DatabaseOptions > > ( ) ;
Original file line number Diff line number Diff line change 11namespace EvolutionaryArchitecture . Fitnet . Reports . DataAccess ;
22
3- using Microsoft . Extensions . Configuration ;
43using Microsoft . Extensions . Options ;
54using System . Data ;
65using Npgsql ;
76
8- internal sealed class DatabaseConnectionFactory : IDatabaseConnectionFactory
7+ internal sealed class DatabaseConnectionFactory ( IOptions < DatabaseOptions > databaseOptions ) : IDatabaseConnectionFactory
98{
10- private readonly IOptions < DatabaseOptions > _databaseOptions ;
119 private NpgsqlConnection ? _connection ;
1210
13- public DatabaseConnectionFactory ( IOptions < DatabaseOptions > databaseOptions )
14- {
15- _databaseOptions = databaseOptions ;
16- }
17-
1811 public IDbConnection Create ( )
1912 {
2013 if ( _connection is { State : ConnectionState . Open } )
2114 {
2215 return _connection ;
2316 }
2417
25- _connection = new NpgsqlConnection ( _databaseOptions . Value . ConnectionString ) ;
18+ _connection = new NpgsqlConnection ( databaseOptions . Value . ConnectionString ) ;
2619 _connection . Open ( ) ;
2720
2821 return _connection ;
You can’t perform that action at this time.
0 commit comments